[IR] fptrunc-of-fptrunc isn't an EliminableCastPair.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 29 May 2015 00:04:30 +0000 (00:04 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 29 May 2015 00:04:30 +0000 (00:04 +0000)
Double and single rounding can produce different results.
This is the IR counterpart to r228911.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238531 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Instructions.cpp
test/Transforms/InstCombine/fpcast.ll

index 1e9d9a5695dce015fad9b8707a84c15cd06e2089..332df4804dae73c8d2b145e4665299f410e1c671 100644 (file)
@@ -2120,7 +2120,7 @@ unsigned CastInst::isEliminableCastPair(
     {  0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToSI         |
     { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // UIToFP         +- firstOp
     { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // SIToFP         |
-    { 99,99,99, 0, 0,99,99, 1, 0,99,99, 4, 0}, // FPTrunc        |
+    { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // FPTrunc        |
     { 99,99,99, 2, 2,99,99,10, 2,99,99, 4, 0}, // FPExt          |
     {  1, 0, 0,99,99, 0, 0,99,99,99, 7, 3, 0}, // PtrToInt       |
     { 99,99,99,99,99,99,99,99,99,11,99,15, 0}, // IntToPtr       |
index 8319624b87c9d00932b90c1cfb1ebbac8e95c37c..93a64e6b49bd4270e6355bff8a5669efa60af862 100644 (file)
@@ -85,3 +85,11 @@ define float @test8(float %V) {
 ; CHECK-NEXT: %[[trunc:.*]] = fptrunc double %frem to float
 ; CHECK-NEXT: ret float %trunc
 }
+
+; CHECK-LABEL: @test_fptrunc_fptrunc
+; CHECK-NOT: fptrunc double {{.*}} to half
+define half @test_fptrunc_fptrunc(double %V) {
+  %t1 = fptrunc double %V to float
+  %t2 = fptrunc float %t1 to half
+  ret half %t2
+}