summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-29 03:27:31 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-29 03:27:31 +0000
commit57b94c8d6a249da464995e651e057645ad6b4c1b (patch)
tree6ac9c8587cacbca4a1877ea3aa15adcc73bcb199
parentd536f2328ededb3aae6563c721c6134c735f1918 (diff)
downloadbcm5719-llvm-57b94c8d6a249da464995e651e057645ad6b4c1b.tar.gz
bcm5719-llvm-57b94c8d6a249da464995e651e057645ad6b4c1b.zip
[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. llvm-svn: 277100
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp3
-rw-r--r--llvm/test/Transforms/InstCombine/cast.ll2
-rw-r--r--llvm/test/Transforms/InstSimplify/pr28725.ll2
3 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 7ee3e8cb4d4..c7f656a09db 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -938,6 +938,9 @@ Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE, Type *DestTy,
Ops[0], Ops.slice(1));
}
+ if (auto *CE = dyn_cast<ConstantExpr>(InstOrCE))
+ return CE->getWithOperands(Ops);
+
switch (Opcode) {
default: return nullptr;
case Instruction::ICmp:
diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll
index e4509112eeb..2acb68738ff 100644
--- a/llvm/test/Transforms/InstCombine/cast.ll
+++ b/llvm/test/Transforms/InstCombine/cast.ll
@@ -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
diff --git a/llvm/test/Transforms/InstSimplify/pr28725.ll b/llvm/test/Transforms/InstSimplify/pr28725.ll
index 420bf4d0e54..b85fc10b6c8 100644
--- a/llvm/test/Transforms/InstSimplify/pr28725.ll
+++ b/llvm/test/Transforms/InstSimplify/pr28725.ll
@@ -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
OpenPOWER on IntegriCloud