Skip to content

Commit f50b3ff

Browse files
committed
[Hexagon] Use InstSimplify instead of ConstantProp
This is the last remaining use of ConstantProp, migrate it to InstSimplify in the goal of removing ConstantProp. Add -hexagon-instsimplify option to enable skipping of instsimplify in tests that can't handle the extra optimization. Differential Revision: https://reviews.llvm.org/D85047
1 parent 4a47f1c commit f50b3ff

File tree

14 files changed

+24
-15
lines changed

14 files changed

+24
-15
lines changed

llvm/include/llvm/Transforms/Scalar.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,13 @@ Pass *createLoopSimplifyCFGPass();
530530
// transformations.
531531
//
532532
Pass *createWarnMissedTransformationsPass();
533+
534+
//===----------------------------------------------------------------------===//
535+
//
536+
// This pass does instruction simplification on each
537+
// instruction in a function.
538+
//
539+
FunctionPass *createInstSimplifyLegacyPass();
533540
} // End llvm namespace
534541

535542
#endif

llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class InstSimplifyPass : public PassInfoMixin<InstSimplifyPass> {
3636
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
3737
};
3838

39-
/// Create a legacy pass that does instruction simplification on each
40-
/// instruction in a function.
41-
FunctionPass *createInstSimplifyLegacyPass();
42-
4339
} // end namespace llvm
4440

4541
#endif // LLVM_TRANSFORMS_UTILS_INSTSIMPLIFYPASS_H

llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ static cl::opt<bool> EnableInitialCFGCleanup("hexagon-initial-cfg-cleanup",
101101
cl::Hidden, cl::ZeroOrMore, cl::init(true),
102102
cl::desc("Simplify the CFG after atomic expansion pass"));
103103

104+
static cl::opt<bool> EnableInstSimplify("hexagon-instsimplify", cl::Hidden,
105+
cl::ZeroOrMore, cl::init(true),
106+
cl::desc("Enable instsimplify"));
107+
104108
/// HexagonTargetMachineModule - Note that this is used on hosts that
105109
/// cannot link in a library unless there are references into the
106110
/// library. In particular, it seems that it is not possible to get
@@ -312,7 +316,8 @@ void HexagonPassConfig::addIRPasses() {
312316
bool NoOpt = (getOptLevel() == CodeGenOpt::None);
313317

314318
if (!NoOpt) {
315-
addPass(createConstantPropagationPass());
319+
if (EnableInstSimplify)
320+
addPass(createInstSimplifyLegacyPass());
316321
addPass(createDeadCodeEliminationPass());
317322
}
318323

llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/IR/Type.h"
2121
#include "llvm/InitializePasses.h"
2222
#include "llvm/Pass.h"
23+
#include "llvm/Transforms/Scalar.h"
2324
#include "llvm/Transforms/Utils.h"
2425
#include "llvm/Transforms/Utils/Local.h"
2526
using namespace llvm;

llvm/test/CodeGen/Hexagon/autohvx/isel-qfalse.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; Make sure we can select QFALSE.
44
; CHECK: vcmp.gt(v0.w,v0.w)

llvm/test/CodeGen/Hexagon/autohvx/isel-setcc-pair.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; Check that a setcc of a vector pair is handled (without crashing).
44
; CHECK: vcmp

llvm/test/CodeGen/Hexagon/bit-bitsplit-regclass.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; Check for successful compilation.
44
; CHECK: r{{[0-9]+}} = insert(r{{[0-9]+}},#1,#31)

llvm/test/CodeGen/Hexagon/hvx-bitcast-v64i1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; Test that LLVM does not assert and bitcast v64i1 to i64 is lowered
44
; without crashing.

llvm/test/CodeGen/Hexagon/isel-simplify-crash.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; This used to crash in SimplifyDemandedBits due to a type mismatch
44
; caused by a missing bitcast in vectorizing mul.

llvm/test/CodeGen/Hexagon/loop_correctness.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -O3 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -O3 -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; CHECK-LABEL: f0:
44
; CHECK: loop0(.LBB{{[0-9]+}}_{{[0-9]+}},#3)

llvm/test/CodeGen/Hexagon/newvaluejump-kill.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -O3 -verify-machineinstrs -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -O3 -verify-machineinstrs -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
22
;
33
; Check that this testcase compiles successfully and that a new-value jump
44
; has been created.

llvm/test/CodeGen/Hexagon/packetize-impdef-1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
22
; REQUIRES: asserts
33

44
; Test that the compiler doesn't assert because IMPLICIT_DEF instructions are

llvm/test/CodeGen/Hexagon/store-vector-pred.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; This test checks that store a vector predicate of type v128i1 is lowered
44
; without crashing.

llvm/test/CodeGen/Hexagon/vect/zext-v4i1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -march=hexagon < %s | FileCheck %s
1+
; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
22

33
; Check that this compiles successfully.
44
; CHECK: vcmph.eq

0 commit comments

Comments
 (0)