[llvm] r277100 - [ConstantFolding] Use ConstantExpr::getWithOperands
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 20:27:31 PDT 2016
Author: majnemer
Date: Thu Jul 28 22:27:31 2016
New Revision: 277100
URL: http://llvm.org/viewvc/llvm-project?rev=277100&view=rev
Log:
[ConstantFolding] Use ConstantExpr::getWithOperands
ConstantExpr::getWithOperands does much of the hard work that
ConstantFoldInstOperandsImpl tries to do but more completely.
This lets us fold ExtractValue/InsertValue expressions.
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/test/Transforms/InstCombine/cast.ll
llvm/trunk/test/Transforms/InstSimplify/pr28725.ll
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=277100&r1=277099&r2=277100&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu Jul 28 22:27:31 2016
@@ -938,6 +938,9 @@ Constant *ConstantFoldInstOperandsImpl(c
Ops[0], Ops.slice(1));
}
+ if (auto *CE = dyn_cast<ConstantExpr>(InstOrCE))
+ return CE->getWithOperands(Ops);
+
switch (Opcode) {
default: return nullptr;
case Instruction::ICmp:
Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=277100&r1=277099&r2=277100&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cast.ll Thu Jul 28 22:27:31 2016
@@ -1375,7 +1375,7 @@ define i16 @PR24763(i8 %V) {
define i64 @PR28745() {
; CHECK-LABEL: @PR28745(
-; CHECK-NEXT: ret i64 zext (i32 extractvalue ({ i32 } select (i1 icmp eq (i16 extractelement (<2 x i16> bitcast (<1 x i32> <i32 1> to <2 x i16>), i32 0), i16 0), { i32 } { i32 1 }, { i32 } zeroinitializer), 0) to i64)
+; CHECK-NEXT: ret i64 1
%b = zext i32 extractvalue ({ i32 } select (i1 icmp eq (i16 extractelement (<2 x i16> bitcast (<1 x i32> <i32 1> to <2 x i16>), i32 0), i16 0), { i32 } { i32 1 }, { i32 } zeroinitializer), 0) to i64
ret i64 %b
Modified: llvm/trunk/test/Transforms/InstSimplify/pr28725.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/pr28725.ll?rev=277100&r1=277099&r2=277100&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/pr28725.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/pr28725.ll Thu Jul 28 22:27:31 2016
@@ -10,4 +10,4 @@ entry:
}
; CHECK-LABEL: @test1(
-; CHECK: ret <2 x i16> <i16 extractvalue (%S select (i1 icmp eq (i16 extractelement (<2 x i16> bitcast (<1 x i32> <i32 1> to <2 x i16>), i32 0), i16 0), %S zeroinitializer, %S { i16 0, i32 1 }), 0), i16 0>
+; CHECK: ret <2 x i16> zeroinitializer
More information about the llvm-commits
mailing list