[llvm] 03e0be9 - [SCCP] Make use of argument attributes in non-ip SCCP

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 06:09:46 PDT 2024


Author: Nikita Popov
Date: 2024-08-26T15:09:33+02:00
New Revision: 03e0be90ca149e27ca608748aa9d21bbd60dea9f

URL: https://github.com/llvm/llvm-project/commit/03e0be90ca149e27ca608748aa9d21bbd60dea9f
DIFF: https://github.com/llvm/llvm-project/commit/03e0be90ca149e27ca608748aa9d21bbd60dea9f.diff

LOG: [SCCP] Make use of argument attributes in non-ip SCCP

Initialize arguments based on attributes instead of hardcoding them
to overdefined. This was already properly done for ipsccp.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/SCCP.cpp
    llvm/test/Transforms/SCCP/range-attribute.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index ce45c58e624e48..caf9f890418e29 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -69,9 +69,9 @@ static bool runSCCP(Function &F, const DataLayout &DL,
   // Mark the first block of the function as being executable.
   Solver.markBlockExecutable(&F.front());
 
-  // Mark all arguments to the function as being overdefined.
+  // Initialize arguments based on attributes.
   for (Argument &AI : F.args())
-    Solver.markOverdefined(&AI);
+    Solver.trackValueOfArgument(&AI);
 
   // Solve for constants.
   bool ResolvedUndefs = true;

diff  --git a/llvm/test/Transforms/SCCP/range-attribute.ll b/llvm/test/Transforms/SCCP/range-attribute.ll
index 4a72c7e0d70c9c..8b156e6f483ed4 100644
--- a/llvm/test/Transforms/SCCP/range-attribute.ll
+++ b/llvm/test/Transforms/SCCP/range-attribute.ll
@@ -6,25 +6,14 @@ declare void @use(i1)
 declare i32 @get_i32()
 
 define void @range_attribute(i32 range(i32 0, 10) %v) {
-; IPSCCP-LABEL: @range_attribute(
-; IPSCCP-NEXT:    call void @use(i1 true)
-; IPSCCP-NEXT:    [[C2:%.*]] = icmp ult i32 [[V:%.*]], 9
-; IPSCCP-NEXT:    call void @use(i1 [[C2]])
-; IPSCCP-NEXT:    call void @use(i1 false)
-; IPSCCP-NEXT:    [[C4:%.*]] = icmp ugt i32 [[V]], 8
-; IPSCCP-NEXT:    call void @use(i1 [[C4]])
-; IPSCCP-NEXT:    ret void
-;
-; SCCP-LABEL: @range_attribute(
-; SCCP-NEXT:    [[C1:%.*]] = icmp ult i32 [[V:%.*]], 10
-; SCCP-NEXT:    call void @use(i1 [[C1]])
-; SCCP-NEXT:    [[C2:%.*]] = icmp ult i32 [[V]], 9
-; SCCP-NEXT:    call void @use(i1 [[C2]])
-; SCCP-NEXT:    [[C3:%.*]] = icmp ugt i32 [[V]], 9
-; SCCP-NEXT:    call void @use(i1 [[C3]])
-; SCCP-NEXT:    [[C4:%.*]] = icmp ugt i32 [[V]], 8
-; SCCP-NEXT:    call void @use(i1 [[C4]])
-; SCCP-NEXT:    ret void
+; CHECK-LABEL: @range_attribute(
+; CHECK-NEXT:    call void @use(i1 true)
+; CHECK-NEXT:    [[C2:%.*]] = icmp ult i32 [[V:%.*]], 9
+; CHECK-NEXT:    call void @use(i1 [[C2]])
+; CHECK-NEXT:    call void @use(i1 false)
+; CHECK-NEXT:    [[C4:%.*]] = icmp ugt i32 [[V]], 8
+; CHECK-NEXT:    call void @use(i1 [[C4]])
+; CHECK-NEXT:    ret void
 ;
   %c1 = icmp ult i32 %v, 10
   call void @use(i1 %c1)


        


More information about the llvm-commits mailing list