[llvm-commits] [llvm] r160823 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp test/Transforms/InstCombine/vec_demanded_elts.ll
Pete Cooper
peter_cooper at apple.com
Thu Jul 26 15:37:04 PDT 2012
Author: pete
Date: Thu Jul 26 17:37:04 2012
New Revision: 160823
URL: http://llvm.org/viewvc/llvm-project?rev=160823&view=rev
Log:
Teach SimplifyDemandedBits how to look through fpext and fptrunc to simplify their operand
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=160823&r1=160822&r2=160823&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Thu Jul 26 17:37:04 2012
@@ -1074,6 +1074,12 @@
// like undef&0. The result is known zero, not undef.
UndefElts &= UndefElts2;
break;
+ case Instruction::FPTrunc:
+ case Instruction::FPExt:
+ TmpV = SimplifyDemandedVectorElts(I->getOperand(0), DemandedElts,
+ UndefElts, Depth+1);
+ if (TmpV) { I->setOperand(0, TmpV); MadeChange = true; }
+ break;
case Instruction::Call: {
IntrinsicInst *II = dyn_cast<IntrinsicInst>(I);
Modified: llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll?rev=160823&r1=160822&r2=160823&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll Thu Jul 26 17:37:04 2012
@@ -162,4 +162,32 @@
ret <4 x float> %shuffle9.i
}
+define <2 x float> @test_fptrunc(double %f) {
+; CHECK: @test_fptrunc
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK-NOT: insertelement
+ %tmp9 = insertelement <4 x double> undef, double %f, i32 0
+ %tmp10 = insertelement <4 x double> %tmp9, double 0.000000e+00, i32 1
+ %tmp11 = insertelement <4 x double> %tmp10, double 0.000000e+00, i32 2
+ %tmp12 = insertelement <4 x double> %tmp11, double 0.000000e+00, i32 3
+ %tmp5 = fptrunc <4 x double> %tmp12 to <4 x float>
+ %ret = shufflevector <4 x float> %tmp5, <4 x float> undef, <2 x i32> <i32 0, i32 1>
+ ret <2 x float> %ret
+}
+
+define <2 x double> @test_fpext(float %f) {
+; CHECK: @test_fpext
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK-NOT: insertelement
+ %tmp9 = insertelement <4 x float> undef, float %f, i32 0
+ %tmp10 = insertelement <4 x float> %tmp9, float 0.000000e+00, i32 1
+ %tmp11 = insertelement <4 x float> %tmp10, float 0.000000e+00, i32 2
+ %tmp12 = insertelement <4 x float> %tmp11, float 0.000000e+00, i32 3
+ %tmp5 = fpext <4 x float> %tmp12 to <4 x double>
+ %ret = shufflevector <4 x double> %tmp5, <4 x double> undef, <2 x i32> <i32 0, i32 1>
+ ret <2 x double> %ret
+}
+
More information about the llvm-commits
mailing list