[llvm-branch-commits] [llvm] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)

Paul Kirth via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 27 16:22:52 PST 2024


https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/83049

>From fc2e672d474442ef83e90c7a41265d6433651b63 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 26 Feb 2024 21:42:24 +0000
Subject: [PATCH 1/3] Refactor option names, and update test

Created using spr 1.3.4
---
 llvm/lib/Passes/PassBuilderPipelines.cpp        |  4 ++--
 llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index e48a31f79cc0c5..9f81ff1899ac5f 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -222,8 +222,8 @@ static cl::opt<bool>
     EnableDFAJumpThreading("enable-dfa-jump-thread",
                            cl::desc("Enable DFA jump threading"),
                            cl::init(false), cl::Hidden);
-static cl::opt<bool>
-    OptSizeDFAJumpThreading("optsize-dfa-jump-thread",
+extern cl::opt<bool>
+    OptSizeDFAJumpThreading("dfa-jump-thread-optsize",
                            cl::desc("Enable DFA jump threading when optimizing for size"),
                            cl::init(false), cl::Hidden);
 
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 9156d756310d14..ce5e823e531e0f 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -110,11 +110,10 @@ static cl::opt<unsigned>
                   cl::desc("Maximum cost accepted for the transformation"),
                   cl::Hidden, cl::init(50));
 
-static cl::opt<bool>
-    IgnoreOptSize("dfa-jump-ignore-optsize",
-                    cl::desc("Enable dfa jump threading, even when optimizing for size"),
-                    cl::Hidden, cl::init(false));
-
+static cl::opt<bool> DFAJumpThreadIgnoreOptSize(
+    "dfa-jump-ignore-optsize",
+    cl::desc("Enable dfa jump threading, even when optimizing for size"),
+    cl::Hidden, cl::init(false));
 
 namespace {
 
@@ -1250,7 +1249,7 @@ struct TransformDFA {
 bool DFAJumpThreading::run(Function &F) {
   LLVM_DEBUG(dbgs() << "\nDFA Jump threading: " << F.getName() << "\n");
 
-  if (!IgnoreOptSize && F.hasOptSize()) {
+  if (!DFAJumpThreadIgnoreOptSize && F.hasOptSize()) {
     LLVM_DEBUG(dbgs() << "Skipping due to the 'minsize' attribute\n");
     return false;
   }

>From ffaa39b064da4d99e1834102ddbb38f0780e4ae7 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 26 Feb 2024 21:55:44 +0000
Subject: [PATCH 2/3] Make variable static + rename

Created using spr 1.3.4
---
 llvm/lib/Passes/PassBuilderPipelines.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 9f81ff1899ac5f..a4db4614c6f830 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -222,8 +222,8 @@ static cl::opt<bool>
     EnableDFAJumpThreading("enable-dfa-jump-thread",
                            cl::desc("Enable DFA jump threading"),
                            cl::init(false), cl::Hidden);
-extern cl::opt<bool>
-    OptSizeDFAJumpThreading("dfa-jump-thread-optsize",
+static cl::opt<bool>
+    DFAJumpThreadingOptSize("dfa-jump-thread-optsize",
                            cl::desc("Enable DFA jump threading when optimizing for size"),
                            cl::init(false), cl::Hidden);
 
@@ -723,7 +723,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   // Re-consider control flow based optimizations after redundancy elimination,
   // redo DCE, etc.
   if (EnableDFAJumpThreading &&
-      ((Level.getSizeLevel() == 0) || OptSizeDFAJumpThreading))
+      ((Level.getSizeLevel() == 0) || DFAJumpThreadingOptSize))
     FPM.addPass(DFAJumpThreadingPass());
 
   FPM.addPass(JumpThreadingPass());

>From 72ecbcc68501c976b3277b28edc6aeafff9f4dad Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Wed, 28 Feb 2024 00:22:40 +0000
Subject: [PATCH 3/3] Fix missing match in test, due to a deleted line

Created using spr 1.3.4
---
 llvm/test/Transforms/DFAJumpThreading/negative.ll | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/test/Transforms/DFAJumpThreading/negative.ll b/llvm/test/Transforms/DFAJumpThreading/negative.ll
index cce6cc887ff206..c822b6613f7334 100644
--- a/llvm/test/Transforms/DFAJumpThreading/negative.ll
+++ b/llvm/test/Transforms/DFAJumpThreading/negative.ll
@@ -188,6 +188,7 @@ define i32 @negative5(i32 %num) minsize {
 ; CHECK-NEXT:    ret i32 0
 ;
 ; IGNORESIZE-LABEL: define i32 @negative5(
+; IGNORESIZE-SAME: i32 [[NUM:%.*]]) #[[ATTR0:[0-9]+]] {
 ; IGNORESIZE-NEXT:  entry:
 ; IGNORESIZE-NEXT:    br label [[FOR_BODY:%.*]]
 ; IGNORESIZE:       for.body:



More information about the llvm-branch-commits mailing list