[Hexagon] Use InstSimplify instead of ConstantProp
authorArthur Eubanks <aeubanks@google.com>
Wed, 29 Jul 2020 20:54:07 +0000 (13:54 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 4 Aug 2020 22:42:39 +0000 (15:42 -0700)
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

14 files changed:
llvm/include/llvm/Transforms/Scalar.h
llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
llvm/test/CodeGen/Hexagon/autohvx/isel-qfalse.ll
llvm/test/CodeGen/Hexagon/autohvx/isel-setcc-pair.ll
llvm/test/CodeGen/Hexagon/bit-bitsplit-regclass.ll
llvm/test/CodeGen/Hexagon/hvx-bitcast-v64i1.ll
llvm/test/CodeGen/Hexagon/isel-simplify-crash.ll
llvm/test/CodeGen/Hexagon/loop_correctness.ll
llvm/test/CodeGen/Hexagon/newvaluejump-kill.ll
llvm/test/CodeGen/Hexagon/packetize-impdef-1.ll
llvm/test/CodeGen/Hexagon/store-vector-pred.ll
llvm/test/CodeGen/Hexagon/vect/zext-v4i1.ll

index 07d968e..8dd59e0 100644 (file)
@@ -530,6 +530,13 @@ Pass *createLoopSimplifyCFGPass();
 // transformations.
 //
 Pass *createWarnMissedTransformationsPass();
+
+//===----------------------------------------------------------------------===//
+//
+// This pass does instruction simplification on each
+// instruction in a function.
+//
+FunctionPass *createInstSimplifyLegacyPass();
 } // End llvm namespace
 
 #endif
index 0c30b62..f36695a 100644 (file)
@@ -36,10 +36,6 @@ public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-/// Create a legacy pass that does instruction simplification on each
-/// instruction in a function.
-FunctionPass *createInstSimplifyLegacyPass();
-
 } // end namespace llvm
 
 #endif // LLVM_TRANSFORMS_UTILS_INSTSIMPLIFYPASS_H
index 03cc7d2..9bcdc89 100644 (file)
@@ -101,6 +101,10 @@ static cl::opt<bool> EnableInitialCFGCleanup("hexagon-initial-cfg-cleanup",
   cl::Hidden, cl::ZeroOrMore, cl::init(true),
   cl::desc("Simplify the CFG after atomic expansion pass"));
 
+static cl::opt<bool> EnableInstSimplify("hexagon-instsimplify", cl::Hidden,
+                                        cl::ZeroOrMore, cl::init(true),
+                                        cl::desc("Enable instsimplify"));
+
 /// HexagonTargetMachineModule - Note that this is used on hosts that
 /// cannot link in a library unless there are references into the
 /// library.  In particular, it seems that it is not possible to get
@@ -312,7 +316,8 @@ void HexagonPassConfig::addIRPasses() {
   bool NoOpt = (getOptLevel() == CodeGenOpt::None);
 
   if (!NoOpt) {
-    addPass(createConstantPropagationPass());
+    if (EnableInstSimplify)
+      addPass(createInstSimplifyLegacyPass());
     addPass(createDeadCodeEliminationPass());
   }
 
index e87b622..7380c9d 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/IR/Type.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
+#include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/Local.h"
 using namespace llvm;
index 9324f52..03f9f81 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
   
 ; Make sure we can select QFALSE.
 ; CHECK: vcmp.gt(v0.w,v0.w)
index 4e49162..fb3be22 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; Check that a setcc of a vector pair is handled (without crashing).
 ; CHECK: vcmp
index 57f7c86..82eb87f 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; Check for successful compilation.
 ; CHECK: r{{[0-9]+}} = insert(r{{[0-9]+}},#1,#31)
index 0834424..c44e7a8 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon  < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-instsimplify=0  < %s | FileCheck %s
 
 ; Test that LLVM does not assert and bitcast v64i1 to i64 is lowered
 ; without crashing.
index 33a9b0e..c13f59a 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; This used to crash in SimplifyDemandedBits due to a type mismatch
 ; caused by a missing bitcast in vectorizing mul.
index df2c3c5..efe74c0 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -O3 < %s | FileCheck %s
+; RUN: llc -march=hexagon -O3 -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; CHECK-LABEL: f0:
 ; CHECK: loop0(.LBB{{[0-9]+}}_{{[0-9]+}},#3)
index e41fcff..9f4ab9d 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -O3 -verify-machineinstrs -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
+; RUN: llc -march=hexagon -O3 -verify-machineinstrs -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
 ;
 ; Check that this testcase compiles successfully and that a new-value jump
 ; has been created.
index 8cb5cff..47f9a86 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-initial-cfg-cleanup=0 -hexagon-instsimplify=0 < %s | FileCheck %s
 ; REQUIRES: asserts
 
 ; Test that the compiler doesn't assert because IMPLICIT_DEF instructions are
index 407a30c..a177f87 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; This test checks that store a vector predicate of type v128i1 is lowered
 ; without crashing.
index bcec154..e5394d9 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-instsimplify=0 < %s | FileCheck %s
 
 ; Check that this compiles successfully.
 ; CHECK: vcmph.eq