Opened 8 years ago

Closed 8 years ago

#1466 closed defect (fixed)

FASTDIV macro incorrect for constant propogation

Reported by: yang Owned by: michael
Priority: normal Component: avutil
Version: git-master Keywords: FASTDIV
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
In file libavutil/x86/intmath.h, around line 30
In above line, "g" need be replaced by "rm".
Otherwise, if "ff_inverse[b]" is a constant and propogate to "mull" instruction by compiler optimization, the "mull" instruction will become a invalid instruction and the compilation will fail.

How to reproduce:
in folder libavutil/x86 folder, write a simple test case as following:
#include "intmath.h"
int main()

int ff_inverse[2]={1,2};
int x = 8;
int r = FASTDIV(x,0);
return r;


compile: gcc test.c -O2
test.c: Assembler messages:
test.c:7: Error: operand type mismatch for "mul"

The operand to the mul instruction can be either register or memory, not an immediate.

This bug will cause Intel C++ compiler compilation failed when IPO optimization is enabled.

Attachments (1)

intmath.h.patch (339 bytes) - added by yang 8 years ago.
patch for libavutil/x86/intmatch.h

Download all attachments as: .zip

Change History (5)

comment:1 follow-up: Changed 8 years ago by cehoyos

  • Keywords FFMPEG mul type mismatch removed
  • Version changed from unspecified to git-master

Could you send a patch to ffmpeg-devel? It will create more attention there.

Changed 8 years ago by yang

patch for libavutil/x86/intmatch.h

comment:2 in reply to: ↑ 1 Changed 8 years ago by yang

Replying to cehoyos:

Could you send a patch to ffmpeg-devel? It will create more attention there.

how to send to ffmpeg-devel? I just attached a patch file here.

comment:3 Changed 8 years ago by cehoyos

Please update the patch, it does not apply anymore.

If you send the patch to the ffmpeg-devel mailing list - - it will create more attention.

comment:4 Changed 8 years ago by michael

  • Resolution set to fixed
  • Status changed from new to closed

Patch updated and applied


Note: See TracTickets for help on using tickets.