[FFmpeg-trac] #1466(avutil:new): FASTDIV macro incorrect for constant propogation

FFmpeg trac at avcodec.org
Tue Jun 19 10:26:29 CEST 2012

#1466: FASTDIV macro incorrect for constant propogation
               Reporter:  yang       |                  Owner:  michael
                   Type:  defect     |                 Status:  new
               Priority:  normal     |              Component:  avutil
                Version:             |               Keywords:  FFMPEG
  unspecified                        |  FASTDIV mul type mismatch
             Blocked By:             |               Blocking:
Reproduced by developer:  0          |  Analyzed by developer:  0
 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.

Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/1466>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list