[LLVMdev] llvm-gcc miscompilation or it's the gcc's rule?
Zhou Sheng
zhousheng00 at gmail.com
Sun Jan 13 22:29:20 PST 2008
Hi,
Here is C function:
uint64_t mul(uint32_t x, uint32_t y) {
return x * y;
}
current llvm-gcc-4.0 with -O3 will compile it to:
define i64 @mul(i32 %x, i32 %y) nounwind {
entry:
%tmp3 = mul i32 %y, %x ; <i32> [#uses=1]
%tmp34 = zext i32 %tmp3 to i64 ; <i64> [#uses=1]
ret i64 %tmp34
}
This seems incorrect. I think it should extend %x, %y to i64 first and then
do the multiplication stuff.
Otherwise, the result may lose some bits if %x, %y are very big.
gcc seems have the same issue. Is this a bug or just gcc's rule?
Thanks,
Sheng.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080113/d59fab67/attachment.html>
More information about the llvm-dev
mailing list