Skip to content

Commit 486ed88

Browse files
committed
[ConstProp] Remove ConstantPropagation
As discussed in http://lists.llvm.org/pipermail/llvm-dev/2020-July/143801.html. Currently no users outside of unit tests. Replace all instances in tests of -constprop with -instsimplify. Notable changes in tests: * vscale.ll - @llvm.sadd.sat.nxv16i8 is evaluated by instsimplify, use a fake intrinsic instead * InsertElement.ll - insertelement undef is removed by instsimplify in @insertelement_undef llvm/test/Transforms/ConstProp moved to llvm/test/Transforms/InstSimplify/ConstProp Reviewed By: lattner, nikic Differential Revision: https://reviews.llvm.org/D85159
1 parent c55db46 commit 486ed88

File tree

99 files changed

+798
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+798
-973
lines changed

llvm/bindings/go/llvm/executionengine_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func TestFactorial(t *testing.T) {
8080
pass := NewPassManager()
8181
defer pass.Dispose()
8282

83-
pass.AddConstantPropagationPass()
8483
pass.AddInstructionCombiningPass()
8584
pass.AddPromoteMemoryToRegisterPass()
8685
pass.AddGVNPass()

llvm/bindings/go/llvm/transforms_scalar.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,5 @@ func (pm PassManager) AddScalarReplAggregatesPassWithThreshold(threshold int) {
4040
}
4141
func (pm PassManager) AddSimplifyLibCallsPass() { C.LLVMAddSimplifyLibCallsPass(pm.C) }
4242
func (pm PassManager) AddTailCallEliminationPass() { C.LLVMAddTailCallEliminationPass(pm.C) }
43-
func (pm PassManager) AddConstantPropagationPass() { C.LLVMAddConstantPropagationPass(pm.C) }
4443
func (pm PassManager) AddDemoteMemoryToRegisterPass() { C.LLVMAddDemoteMemoryToRegisterPass(pm.C) }
4544
func (pm PassManager) AddVerifierPass() { C.LLVMAddVerifierPass(pm.C) }

llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ external add_tail_call_elimination
161161
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
162162
= "llvm_add_tail_call_elimination"
163163

164-
(** See the [llvm::createConstantPropagationPass] function. *)
165-
external add_constant_propagation
166-
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
167-
= "llvm_add_constant_propagation"
168-
169164
(** See the [llvm::createDemoteMemoryToRegisterPass] function. *)
170165
external add_memory_to_register_demotion
171166
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit

llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,6 @@ CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) {
200200
return Val_unit;
201201
}
202202

203-
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
204-
CAMLprim value llvm_add_constant_propagation(LLVMPassManagerRef PM) {
205-
LLVMAddConstantPropagationPass(PM);
206-
return Val_unit;
207-
}
208-
209203
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
210204
CAMLprim value llvm_add_demote_memory_to_register(LLVMPassManagerRef PM) {
211205
LLVMAddDemoteMemoryToRegisterPass(PM);

llvm/docs/CommandLine.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Parsing a list of options
475475
Now that we have the standard run-of-the-mill argument types out of the way,
476476
lets get a little wild and crazy. Lets say that we want our optimizer to accept
477477
a **list** of optimizations to perform, allowing duplicates. For example, we
478-
might want to run: "``compiler -dce -constprop -inline -dce -strip``". In this
478+
might want to run: "``compiler -dce -instsimplify -inline -dce -strip``". In this
479479
case, the order of the arguments and the number of appearances is very
480480
important. This is what the "``cl::list``" template is for. First, start by
481481
defining an enum of the optimizations that you would like to perform:
@@ -484,7 +484,7 @@ defining an enum of the optimizations that you would like to perform:
484484

485485
enum Opts {
486486
// 'inline' is a C++ keyword, so name it 'inlining'
487-
dce, constprop, inlining, strip
487+
dce, instsimplify, inlining, strip
488488
};
489489

490490
Then define your "``cl::list``" variable:
@@ -494,7 +494,7 @@ Then define your "``cl::list``" variable:
494494
cl::list<Opts> OptimizationList(cl::desc("Available Optimizations:"),
495495
cl::values(
496496
clEnumVal(dce , "Dead Code Elimination"),
497-
clEnumVal(constprop , "Constant Propagation"),
497+
clEnumVal(instsimplify , "Instruction Simplification"),
498498
clEnumValN(inlining, "inline", "Procedure Integration"),
499499
clEnumVal(strip , "Strip Symbols")));
500500

@@ -553,16 +553,16 @@ Reworking the above list example, we could replace `cl::list`_ with `cl::bits`_:
553553
cl::bits<Opts> OptimizationBits(cl::desc("Available Optimizations:"),
554554
cl::values(
555555
clEnumVal(dce , "Dead Code Elimination"),
556-
clEnumVal(constprop , "Constant Propagation"),
556+
clEnumVal(instsimplify , "Instruction Simplification"),
557557
clEnumValN(inlining, "inline", "Procedure Integration"),
558558
clEnumVal(strip , "Strip Symbols")));
559559

560-
To test to see if ``constprop`` was specified, we can use the ``cl:bits::isSet``
560+
To test to see if ``instsimplify`` was specified, we can use the ``cl:bits::isSet``
561561
function:
562562

563563
.. code-block:: c++
564564

565-
if (OptimizationBits.isSet(constprop)) {
565+
if (OptimizationBits.isSet(instsimplify)) {
566566
...
567567
}
568568

llvm/docs/Passes.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -460,27 +460,6 @@ shared. This is useful because some passes (i.e., TraceValues) insert a lot of
460460
string constants into the program, regardless of whether or not an existing
461461
string is available.
462462

463-
``-constprop``: Simple constant propagation
464-
-------------------------------------------
465-
466-
This pass implements constant propagation and merging. It looks for
467-
instructions involving only constant operands and replaces them with a constant
468-
value instead of an instruction. For example:
469-
470-
.. code-block:: llvm
471-
472-
add i32 1, 2
473-
474-
becomes
475-
476-
.. code-block:: llvm
477-
478-
i32 3
479-
480-
NOTE: this pass has a habit of making definitions be dead. It is a good idea
481-
to run a :ref:`Dead Instruction Elimination <passes-die>` pass sometime after
482-
running this pass.
483-
484463
.. _passes-dce:
485464

486465
``-dce``: Dead Code Elimination

llvm/include/llvm-c/Transforms/Scalar.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
125125
/** See llvm::createTailCallEliminationPass function. */
126126
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
127127

128-
/** See llvm::createConstantPropagationPass function. */
129-
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM);
130-
131128
/** See llvm::demotePromoteMemoryToRegisterPass function. */
132129
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);
133130

llvm/include/llvm/InitializePasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ void initializeCalledValuePropagationLegacyPassPass(PassRegistry &);
113113
void initializeCodeGenPreparePass(PassRegistry&);
114114
void initializeConstantHoistingLegacyPassPass(PassRegistry&);
115115
void initializeConstantMergeLegacyPassPass(PassRegistry&);
116-
void initializeConstantPropagationPass(PassRegistry&);
117116
void initializeControlHeightReductionLegacyPassPass(PassRegistry&);
118117
void initializeCorrelatedValuePropagationPass(PassRegistry&);
119118
void initializeCostModelAnalysisPass(PassRegistry&);

llvm/include/llvm/LinkAllPasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ namespace {
8989
(void) llvm::createLibCallsShrinkWrapPass();
9090
(void) llvm::createCalledValuePropagationPass();
9191
(void) llvm::createConstantMergePass();
92-
(void) llvm::createConstantPropagationPass();
9392
(void) llvm::createControlHeightReductionLegacyPass();
9493
(void) llvm::createCostModelAnalysisPass();
9594
(void) llvm::createDeadArgEliminationPass();

llvm/include/llvm/Transforms/Scalar.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ class FunctionPass;
2424
class ModulePass;
2525
class Pass;
2626

27-
//===----------------------------------------------------------------------===//
28-
//
29-
// ConstantPropagation - A worklist driven constant propagation pass
30-
//
31-
FunctionPass *createConstantPropagationPass();
32-
3327
//===----------------------------------------------------------------------===//
3428
//
3529
// AlignmentFromAssumptions - Use assume intrinsics to set load/store

llvm/lib/Transforms/Scalar/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ add_llvm_component_library(LLVMScalarOpts
44
BDCE.cpp
55
CallSiteSplitting.cpp
66
ConstantHoisting.cpp
7-
ConstantProp.cpp
87
CorrelatedValuePropagation.cpp
98
DCE.cpp
109
DeadStoreElimination.cpp

llvm/lib/Transforms/Scalar/ConstantProp.cpp

Lines changed: 0 additions & 121 deletions
This file was deleted.

llvm/lib/Transforms/Scalar/Scalar.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
3838
initializeAlignmentFromAssumptionsPass(Registry);
3939
initializeCallSiteSplittingLegacyPassPass(Registry);
4040
initializeConstantHoistingLegacyPassPass(Registry);
41-
initializeConstantPropagationPass(Registry);
4241
initializeCorrelatedValuePropagationPass(Registry);
4342
initializeDCELegacyPassPass(Registry);
4443
initializeDeadInstEliminationPass(Registry);
@@ -248,10 +247,6 @@ void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) {
248247
unwrap(PM)->add(createTailCallEliminationPass());
249248
}
250249

251-
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) {
252-
unwrap(PM)->add(createConstantPropagationPass());
253-
}
254-
255250
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
256251
unwrap(PM)->add(createDemoteRegisterToMemoryPass());
257252
}

llvm/test/Assembler/2002-04-07-HexFloatConstants.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
; of the bug that was causing the Olden Health benchmark to output incorrect
66
; results!
77
;
8-
; RUN: opt -constprop -S > %t.1 < %s
9-
; RUN: llvm-as < %s | llvm-dis | llvm-as | opt -constprop | \
8+
; RUN: opt -instsimplify -S > %t.1 < %s
9+
; RUN: llvm-as < %s | llvm-dis | llvm-as | opt -instsimplify | \
1010
; RUN: llvm-dis > %t.2
1111
; RUN: diff %t.1 %t.2
1212
; RUN: verify-uselistorder %s

llvm/test/Bitcode/extractelement.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -constprop | llvm-dis -disable-output
1+
; RUN: opt < %s -instsimplify | llvm-dis -disable-output
22
; RUN: verify-uselistorder < %s
33
; PR3465
44

llvm/test/Other/2002-03-11-ConstPropCrash.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2002-03-11-ConstPropCrash.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;
66
; Fixed by adding new arguments to ConstantFoldTerminator
77
;
8-
; RUN: opt < %s -constprop
8+
; RUN: opt < %s -instsimplify
99

1010
define void @build_tree(i32 %ml) {
1111
; <label>:0

llvm/test/Transforms/ConstProp/2002-05-03-DivideByZeroException.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2002-05-03-DivideByZeroException.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Make sure that the constant propogator doesn't divide by zero!
22
;
3-
; RUN: opt < %s -constprop
3+
; RUN: opt < %s -instsimplify
44
;
55

66
define i32 @test() {

llvm/test/Transforms/ConstProp/2002-05-03-NotOperator.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2002-05-03-NotOperator.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
; Fix #2: The unary not instruction now no longer exists. Change to xor.
66

7-
; RUN: opt < %s -constprop -S | \
7+
; RUN: opt < %s -instsimplify -S | \
88
; RUN: not grep "i32 0"
99

1010
define i32 @test1() {

llvm/test/Transforms/ConstProp/2002-09-03-SetCC-Bools.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2002-09-03-SetCC-Bools.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; SetCC on boolean values was not implemented!
22

3-
; RUN: opt < %s -constprop -die -S | \
3+
; RUN: opt < %s -instsimplify -die -S | \
44
; RUN: not grep set
55

66
define i1 @test1() {

llvm/test/Transforms/ConstProp/2003-05-12-DivideError.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2003-05-12-DivideError.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Make sure that the constant propagator doesn't cause a sigfpe
22
;
3-
; RUN: opt < %s -constprop
3+
; RUN: opt < %s -instsimplify
44
;
55

66
define i32 @test() {

llvm/test/Transforms/ConstProp/2005-01-28-SetCCGEP.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2005-01-28-SetCCGEP.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -constprop -S | \
1+
; RUN: opt < %s -instsimplify -S | \
22
; RUN: not grep "ret i1 false"
33

44
@b = external global [2 x { }] ; <[2 x { }]*> [#uses=2]

llvm/test/Transforms/ConstProp/2006-11-30-vector-cast.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2006-11-30-vector-cast.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
; RUN: opt < %s -constprop -S | \
1+
; RUN: opt < %s -instsimplify -S | \
22
; RUN: grep "i32 -1"
3-
; RUN: opt < %s -constprop -S | \
3+
; RUN: opt < %s -instsimplify -S | \
44
; RUN: not grep zeroinitializer
55

66
define <4 x i32> @test() {

llvm/test/Transforms/ConstProp/2006-12-01-bool-casts.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2006-12-01-bool-casts.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
; RUN: opt < %s -constprop -S | \
1+
; RUN: opt < %s -instsimplify -S | \
22
; RUN: grep "ret i32 -1"
3-
; RUN: opt < %s -constprop -S | \
3+
; RUN: opt < %s -instsimplify -S | \
44
; RUN: grep "ret i32 1"
55

66
define i32 @test1() {

llvm/test/Transforms/ConstProp/2007-02-05-BitCast.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2007-02-05-BitCast.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -constprop -S | grep 1065353216
1+
; RUN: opt < %s -instsimplify -S | grep 1065353216
22

33
define i32 @test() {
44
%A = bitcast float 1.000000e+00 to i32 ; <i32> [#uses=1]

llvm/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll renamed to llvm/test/Transforms/InstSimplify/ConstProp/2008-07-07-VectorCompare.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -constprop -disable-output
1+
; RUN: opt < %s -instsimplify -disable-output
22
; PR2529
33
define <4 x i1> @test1(i32 %argc, i8** %argv) {
44
entry:

0 commit comments

Comments
 (0)