https://llvm.org/bugs/show_bug.cgi?id=24805
Bug ID: 24805
Summary: Inconsistent behavior in FP_TO_UINT compared to
gcc-4.9
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: AArch64
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Consider the following test case:
==========================================================
#include <stdio.h>
unsigned char a = 255;
double b = 18;
int main() {
printf("%d", a *= b);
return 0;
}
==========================================================
command: clang -target aarch64 -O2 test.c
The output is 4590 in clang, but 238 in GCC4.9
I'm not sure it is a bug or just an undefined behavior, since the value if the
fp is larger than range of i8
I found that the node (i8 = FP_TO_UINT f64) is promoted to
(i32 = FP_TO_SINT f64) + (i32 = AssertZext i8) in
DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT
And the AssertZExt node is combined with the AND node(for zero extend
operation) after that when DAG combining since the DAGCombiner assumes the bit9
to bit31 of AssertZExt node are zeros.
As a result, the value is not truncated to i8.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs