ConstantExpr::getWithOperands does much of the hard work that
ConstantFoldInstOperandsImpl tries to do but more completely.
This lets us fold ExtractValue/InsertValue expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277100
91177308-0d34-0410-b5e6-
96231b3b80d8
Ops[0], Ops.slice(1));
}
+ if (auto *CE = dyn_cast<ConstantExpr>(InstOrCE))
+ return CE->getWithOperands(Ops);
+
switch (Opcode) {
default: return nullptr;
case Instruction::ICmp:
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
}
; 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