[llvm] 72e0846 - [LVI] Don't bail on overdefined value in select

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 4 02:11:15 PDT 2021


Author: Nikita Popov
Date: 2021-04-04T11:11:01+02:00
New Revision: 72e0846ef87d0d3b5960238bc47fc0cc6f04d848

URL: https://github.com/llvm/llvm-project/commit/72e0846ef87d0d3b5960238bc47fc0cc6f04d848
DIFF: https://github.com/llvm/llvm-project/commit/72e0846ef87d0d3b5960238bc47fc0cc6f04d848.diff

LOG: [LVI] Don't bail on overdefined value in select

Even if one of the operands is overdefined, we may still produce
a non-overdefined result, e.g. due to a min/max operation. This
matches our handling elsewhere, e.g. for binary operators.

The slot poisoning comment refers to a much older LVI cache
implementation.

Added: 
    

Modified: 
    llvm/lib/Analysis/LazyValueInfo.cpp
    llvm/test/Transforms/CorrelatedValuePropagation/and.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index c1a8d3d25bf5..75fef34eaf4a 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -801,22 +801,12 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueSelect(
     return None;
   ValueLatticeElement &TrueVal = *OptTrueVal;
 
-  // If we hit overdefined, don't ask more queries.  We want to avoid poisoning
-  // extra slots in the table if we can.
-  if (TrueVal.isOverdefined())
-    return ValueLatticeElement::getOverdefined();
-
   Optional<ValueLatticeElement> OptFalseVal =
       getBlockValue(SI->getFalseValue(), BB);
   if (!OptFalseVal)
     return None;
   ValueLatticeElement &FalseVal = *OptFalseVal;
 
-  // If we hit overdefined, don't ask more queries.  We want to avoid poisoning
-  // extra slots in the table if we can.
-  if (FalseVal.isOverdefined())
-    return ValueLatticeElement::getOverdefined();
-
   if (TrueVal.isConstantRange() && FalseVal.isConstantRange()) {
     const ConstantRange &TrueCR = TrueVal.getConstantRange();
     const ConstantRange &FalseCR = FalseVal.getConstantRange();

diff  --git a/llvm/test/Transforms/CorrelatedValuePropagation/and.ll b/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
index 0fd2955d6262..195dd8b9b4d6 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
@@ -129,8 +129,7 @@ define i32 @min_and(i32 %a) {
 ; CHECK-LABEL: @min_and(
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[A:%.*]], 127
 ; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[CMP]], i32 [[A]], i32 127
-; CHECK-NEXT:    [[AND:%.*]] = and i32 [[SEL]], 127
-; CHECK-NEXT:    ret i32 [[AND]]
+; CHECK-NEXT:    ret i32 [[SEL]]
 ;
   %cmp = icmp ult i32 %a, 127
   %sel = select i1 %cmp, i32 %a, i32 127
@@ -142,8 +141,7 @@ define i32 @min_and_comm(i32 %a) {
 ; CHECK-LABEL: @min_and_comm(
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp uge i32 [[A:%.*]], 127
 ; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[CMP]], i32 127, i32 [[A]]
-; CHECK-NEXT:    [[AND:%.*]] = and i32 [[SEL]], 127
-; CHECK-NEXT:    ret i32 [[AND]]
+; CHECK-NEXT:    ret i32 [[SEL]]
 ;
   %cmp = icmp uge i32 %a, 127
   %sel = select i1 %cmp, i32 127, i32 %a


        


More information about the llvm-commits mailing list