[llvm] r275363 - [IPSCCP] Constant fold struct argument/instructions when all the lattice values are constant.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 19:51:41 PDT 2016
Author: davide
Date: Wed Jul 13 21:51:41 2016
New Revision: 275363
URL: http://llvm.org/viewvc/llvm-project?rev=275363&view=rev
Log:
[IPSCCP] Constant fold struct argument/instructions when all the lattice values are constant.
This now should also work with the interprocedural variant of the pass.
Slightly easier now that the yak is shaved.
Differential Revision: http://reviews.llvm.org/D22329
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=275363&r1=275362&r2=275363&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Jul 13 21:51:41 2016
@@ -1766,11 +1766,8 @@ static bool runIPSCCP(Module &M, const D
if (Solver.isBlockExecutable(&F.front())) {
for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E;
++AI) {
- if (AI->use_empty() || AI->getType()->isStructTy()) continue;
-
- // TODO: Could use getStructLatticeValueFor to find out if the entire
- // result is a constant and replace it entirely if so.
-
+ if (AI->use_empty())
+ continue;
if (tryToReplaceWithConstant(Solver, &*AI))
++IPNumArgsElimed;
}
@@ -1793,12 +1790,8 @@ static bool runIPSCCP(Module &M, const D
for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) {
Instruction *Inst = &*BI++;
- if (Inst->getType()->isVoidTy() || Inst->getType()->isStructTy())
+ if (Inst->getType()->isVoidTy())
continue;
-
- // TODO: Could use getStructLatticeValueFor to find out if the entire
- // result is a constant and replace it entirely if so.
-
if (tryToReplaceInstWithConstant(
Solver, Inst,
!isa<CallInst>(Inst) &&
Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=275363&r1=275362&r2=275363&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original)
+++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Wed Jul 13 21:51:41 2016
@@ -82,6 +82,10 @@ define internal {i64,i64} @test4a() {
ret {i64,i64} %b
}
+; CHECK-LABEL: define internal { i64, i64 } @test4a(
+; CHECK-NEXT: ret { i64, i64 } { i64 5, i64 4 }
+; CHECK-NEXT: }
+
define i64 @test4b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%a = invoke {i64,i64} @test4a()
to label %A unwind label %B
@@ -130,7 +134,7 @@ B:
; CHECK: define i64 @test5b()
; CHECK: A:
-; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } %a)
+; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } { i64 5, i64 4 })
; CHECK-NEXT: ret i64 5
define internal i64 @test5c({i64,i64} %a) {
@@ -163,8 +167,7 @@ define internal %T @test7a(i32 %A) {
%mrv1 = insertvalue %T %mrv0, i32 %A, 1
ret %T %mrv1
; CHECK-LABEL: @test7a(
-; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0
-; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1
+; CHECK-NEXT: ret %T { i32 18, i32 17 }
}
define i32 @test7b() {
@@ -208,6 +211,12 @@ entry:
ret void
}
+; CHECK-LABEL: define void @test9(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: %local_foo = alloca {}
+; CHECK-NEXT: store {} zeroinitializer, {}* %local_foo
+; CHECK-NEXT: ret void
+
declare i32 @__gxx_personality_v0(...)
;;======================== test10
More information about the llvm-commits
mailing list