From c0d1ce55acd60111fc17044c0c11dab1182c91af Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Fri, 29 May 2015 00:04:30 +0000 Subject: [PATCH] [IR] fptrunc-of-fptrunc isn't an EliminableCastPair. 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 | 2 +- test/Transforms/InstCombine/fpcast.ll | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 1e9d9a5695d..332df4804da 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -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 | diff --git a/test/Transforms/InstCombine/fpcast.ll b/test/Transforms/InstCombine/fpcast.ll index 8319624b87c..93a64e6b49b 100644 --- a/test/Transforms/InstCombine/fpcast.ll +++ b/test/Transforms/InstCombine/fpcast.ll @@ -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 +} -- 2.34.1