https://bugs.llvm.org/show_bug.cgi?id=44680
Bug ID: 44680
Summary: Optimizer breaks compare for the negation of the
signed integer -0x80000000
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: unassignedclangb...@nondot.org
Reporter: i...@artsoft.nl
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Created attachment 23065
--> https://bugs.llvm.org/attachment.cgi?id=23065&action=edit
simple program to reproduce the bug
The following 2 lines of code:
int NaN = -0x80000000;
printf ( "%d < 0 : %s\n", -NaN, (-NaN) < 0 ? "true" : "false" );
Correctly prints when build without optimizations:
-2147483648 < 0 : true
But incorrectly prints when build with -O1 or higher:
-2147483648 < 0 : false
_______________________________________________
-0x80000000 has no positive counterpart as 0x7FFFFFFF is the max positive
value of an int32. So when you negate -0x80000000 it remains -0x80000000.
I think the optimizer rewrites the statement "( -Nan ) < 0" to "Nan > 0", but
this changes the result.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs