[llvm-bugs] [Bug 24805] New: Inconsistent behavior in FP_TO_UINT compared to gcc-4.9

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 13 18:37:55 PDT 2015


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: unassignedbugs at nondot.org
          Reporter: koviankevin at hotmail.com
                CC: llvm-bugs at lists.llvm.org
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150914/65ce47ad/attachment.html>


More information about the llvm-bugs mailing list