@@ -795,6 +795,13 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
795
795
}
796
796
}
797
797
798
+ static ConstantRange getConstantRangeOrFull (const ValueLatticeElement &Val,
799
+ Type *Ty, const DataLayout &DL) {
800
+ if (Val.isConstantRange ())
801
+ return Val.getConstantRange ();
802
+ return ConstantRange::getFull (DL.getTypeSizeInBits (Ty));
803
+ }
804
+
798
805
Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueSelect (
799
806
SelectInst *SI, BasicBlock *BB) {
800
807
// Recurse on our inputs if needed
@@ -810,9 +817,11 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueSelect(
810
817
return None;
811
818
ValueLatticeElement &FalseVal = *OptFalseVal;
812
819
813
- if (TrueVal.isConstantRange () && FalseVal.isConstantRange ()) {
814
- const ConstantRange &TrueCR = TrueVal.getConstantRange ();
815
- const ConstantRange &FalseCR = FalseVal.getConstantRange ();
820
+ if (TrueVal.isConstantRange () || FalseVal.isConstantRange ()) {
821
+ const ConstantRange &TrueCR =
822
+ getConstantRangeOrFull (TrueVal, SI->getType (), DL);
823
+ const ConstantRange &FalseCR =
824
+ getConstantRangeOrFull (FalseVal, SI->getType (), DL);
816
825
Value *LHS = nullptr ;
817
826
Value *RHS = nullptr ;
818
827
SelectPatternResult SPR = matchSelectPattern (SI, LHS, RHS);
@@ -879,13 +888,7 @@ Optional<ConstantRange> LazyValueInfoImpl::getRangeFor(Value *V,
879
888
Optional<ValueLatticeElement> OptVal = getBlockValue (V, BB, CxtI);
880
889
if (!OptVal)
881
890
return None;
882
-
883
- ValueLatticeElement &Val = *OptVal;
884
- if (Val.isConstantRange ())
885
- return Val.getConstantRange ();
886
-
887
- const unsigned OperandBitWidth = DL.getTypeSizeInBits (V->getType ());
888
- return ConstantRange::getFull (OperandBitWidth);
891
+ return getConstantRangeOrFull (*OptVal, V->getType (), DL);
889
892
}
890
893
891
894
Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueCast (
0 commit comments