Opened 12 years ago

Closed 12 years ago

#1466 closed defect (fixed)

FASTDIV macro incorrect for constant propogation

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

Description

Summary of the bug:
In file libavutil/x86/intmath.h, around line 30
"g"(ff_inverse[b])\
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 12 years ago.
patch for libavutil/x86/intmatch.h

Download all attachments as: .zip

Change History (5)

comment:1 by Carl Eugen Hoyos, 12 years ago

Keywords: FFMPEG mul type mismatch removed
Version: unspecifiedgit-master

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

by yang, 12 years ago

Attachment: intmath.h.patch added

patch for libavutil/x86/intmatch.h

in reply to:  1 comment:2 by yang, 12 years ago

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 by Carl Eugen Hoyos, 12 years ago

Please update the patch, it does not apply anymore.

If you send the patch to the ffmpeg-devel mailing list - http://ffmpeg.org/mailman/listinfo/ffmpeg-devel - it will create more attention.

comment:4 by Michael Niedermayer, 12 years ago

Resolution: fixed
Status: newclosed

Patch updated and applied

thanks

Note: See TracTickets for help on using tickets.