[llvm] [LVI][CVP] propagates `undef` to range and `abs` (PR #68190)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 06:25:51 PDT 2023
https://github.com/nikic requested changes to this pull request.
I don't think this is the right approach to fixing this. The core fix here should be along these lines:
```llvm
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 0892aa9d75fb..789a02ed329c 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -801,7 +801,7 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
static ConstantRange getConstantRangeOrFull(const ValueLatticeElement &Val,
Type *Ty, const DataLayout &DL) {
- if (Val.isConstantRange())
+ if (Val.isConstantRange(/*UndefAllowed*/ false))
return Val.getConstantRange();
return ConstantRange::getFull(DL.getTypeSizeInBits(Ty));
}
```
That is, when converting to ConstantRange, we should treat undef like a full range.
The way you are propagating undef here is basically as if it were poison, but this doesn't match its semantics. `zext CR|undef` does not result in `CR.zext()|undef`, because the top bits are guaranteed to be zero even if the input is undef.
I think this approach will result in a simpler and more robust fix.
https://github.com/llvm/llvm-project/pull/68190
More information about the llvm-commits
mailing list