[PATCH] D78393: [SCCP] Drop unnecessary early exit for ExtractValueInst.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 14:09:38 PDT 2020


fhahn updated this revision to Diff 259383.
fhahn added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78393/new/

https://reviews.llvm.org/D78393

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/conditions-ranges.ll
  llvm/test/Transforms/SCCP/constant-range-struct.ll


Index: llvm/test/Transforms/SCCP/constant-range-struct.ll
===================================================================
--- llvm/test/Transforms/SCCP/constant-range-struct.ll
+++ llvm/test/Transforms/SCCP/constant-range-struct.ll
@@ -159,6 +159,5 @@
   %c.4 = icmp ugt i64 %v2, 250
   call void @use(i1 %c.4)
 
-
   ret void
 }
Index: llvm/test/Transforms/SCCP/conditions-ranges.ll
===================================================================
--- llvm/test/Transforms/SCCP/conditions-ranges.ll
+++ llvm/test/Transforms/SCCP/conditions-ranges.ll
@@ -989,6 +989,12 @@
 ; CHECK-NEXT:    call void @use(i1 [[F_2]])
 ; CHECK-NEXT:    [[F_3:%.*]] = icmp ugt i32 [[A]], 100
 ; CHECK-NEXT:    call void @use(i1 [[F_3]])
+; CHECK-NEXT:    [[F_4:%.*]] = icmp eq i32 [[B]], 0
+; CHECK-NEXT:    call void @use(i1 [[F_3]])
+; CHECK-NEXT:    [[F_5:%.*]] = icmp eq i32 [[B]], 20
+; CHECK-NEXT:    call void @use(i1 [[F_5]])
+; CHECK-NEXT:    [[F_6:%.*]] = icmp ugt i32 [[B]], 100
+; CHECK-NEXT:    call void @use(i1 [[F_6]])
 ; CHECK-NEXT:    [[T_1:%.*]] = icmp ult i32 [[A]], 100
 ; CHECK-NEXT:    call void @use(i1 [[T_1]])
 ; CHECK-NEXT:    [[T_2:%.*]] = icmp ne i32 [[A]], 20
@@ -1001,8 +1007,8 @@
 ; CHECK-NEXT:    call void @use(i1 [[C_3]])
 ; CHECK-NEXT:    ret void
 ; CHECK:       false:
-; CHECK-NEXT:    [[F_4:%.*]] = icmp eq i32 [[A]], 50
-; CHECK-NEXT:    call void @use(i1 [[F_4]])
+; CHECK-NEXT:    [[F_7:%.*]] = icmp eq i32 [[A]], 50
+; CHECK-NEXT:    call void @use(i1 [[F_7]])
 ; CHECK-NEXT:    [[T_3:%.*]] = icmp ne i32 [[A]], 50
 ; CHECK-NEXT:    call void @use(i1 [[T_3]])
 ; CHECK-NEXT:    [[C_4:%.*]] = icmp eq i32 [[A]], 10
@@ -1027,6 +1033,13 @@
   call void @use(i1 %f.2)
   %f.3 = icmp ugt i32 %a, 100
   call void @use(i1 %f.3)
+  %f.4 = icmp eq i32 %b, 0
+  call void @use(i1 %f.3)
+  %f.5 = icmp eq i32 %b, 20
+  call void @use(i1 %f.5)
+  %f.6 = icmp ugt i32 %b, 100
+  call void @use(i1 %f.6)
+
 
   ; Conditions below are true.
   %t.1 = icmp ult i32 %a, 100
@@ -1045,8 +1058,8 @@
 
 false:
   ; Conditions below are false;
-  %f.4 = icmp eq i32 %a, 50
-  call void @use(i1 %f.4)
+  %f.7 = icmp eq i32 %a, 50
+  call void @use(i1 %f.7)
 
   ; Conditions below are true;
   %t.3 = icmp ne i32 %a, 50
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SCCP.cpp
+++ llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -810,16 +810,16 @@
 }
 
 void SCCPSolver::visitExtractValueInst(ExtractValueInst &EVI) {
-  // ResolvedUndefsIn might mark I as overdefined. Bail out, even if we would
-  // discover a concrete value later.
-  if (isOverdefined(ValueState[&EVI]))
-    return (void)markOverdefined(&EVI);
-
   // If this returns a struct, mark all elements over defined, we don't track
   // structs in structs.
   if (EVI.getType()->isStructTy())
     return (void)markOverdefined(&EVI);
 
+  // ResolvedUndefsIn might mark I as overdefined. Bail out, even if we would
+  // discover a concrete value later.
+  if (ValueState[&EVI].isOverdefined())
+    return (void)markOverdefined(&EVI);
+
   // If this is extracting from more than one level of struct, we don't know.
   if (EVI.getNumIndices() != 1)
     return (void)markOverdefined(&EVI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78393.259383.patch
Type: text/x-patch
Size: 3253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/8fc65353/attachment.bin>


More information about the llvm-commits mailing list