[llvm] 352b612 - [SCCP] Drop unnecessary early exit for ExtractValueInst.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 14:08:19 PDT 2020
Author: Florian Hahn
Date: 2020-04-22T22:07:59+01:00
New Revision: 352b612a7141bdb07e8b043f4ec9b8c2d5faca45
URL: https://github.com/llvm/llvm-project/commit/352b612a7141bdb07e8b043f4ec9b8c2d5faca45
DIFF: https://github.com/llvm/llvm-project/commit/352b612a7141bdb07e8b043f4ec9b8c2d5faca45.diff
LOG: [SCCP] Drop unnecessary early exit for ExtractValueInst.
visitExtractValueInst uses mergeInValue, so it already can handle
constant ranges. Initially the early exit was using isOverdefined to
keep things as NFC during the initial move to ValueLatticeElement.
As the function already supports constant ranges, it can just use
ValueState[&I].isOverdefined.
Reviewers: efriedma, mssimpso, davide
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D78393
Added:
Modified:
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/SCCP/conditions-ranges.ll
llvm/test/Transforms/SCCP/constant-range-struct.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 6d640fe8f9f4..1b159dd69d28 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -810,16 +810,16 @@ void SCCPSolver::visitCastInst(CastInst &I) {
}
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);
diff --git a/llvm/test/Transforms/SCCP/conditions-ranges.ll b/llvm/test/Transforms/SCCP/conditions-ranges.ll
index 400c49e337df..baaf8cbf1c2f 100644
--- a/llvm/test/Transforms/SCCP/conditions-ranges.ll
+++ b/llvm/test/Transforms/SCCP/conditions-ranges.ll
@@ -989,6 +989,12 @@ define void @f18_conditions_chained_and(i32 %a, i32 %b) {
; 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 @@ define void @f18_conditions_chained_and(i32 %a, i32 %b) {
; 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 @@ true: ; %a in [21, 100)
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 @@ true: ; %a in [21, 100)
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
diff --git a/llvm/test/Transforms/SCCP/constant-range-struct.ll b/llvm/test/Transforms/SCCP/constant-range-struct.ll
index d3c5e5513b9e..6a602feefa4c 100644
--- a/llvm/test/Transforms/SCCP/constant-range-struct.ll
+++ b/llvm/test/Transforms/SCCP/constant-range-struct.ll
@@ -159,6 +159,5 @@ define void @struct2_caller() {
%c.4 = icmp ugt i64 %v2, 250
call void @use(i1 %c.4)
-
ret void
}
More information about the llvm-commits
mailing list