diff options
author | Sanjay Patel <spatel@rotateright.com> | 2022-01-23 11:11:26 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2022-01-23 11:22:48 -0500 |
commit | 2e26633af0c88ea23e3e8783ef60e621f282d3fb (patch) | |
tree | 9134d0a93b3b385ffd122bb7cc0e8df95f474c40 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 7c66aaddb128dc0f342830c1efaeb7a278bfc48c (diff) | |
download | llvm-2e26633af0c88ea23e3e8783ef60e621f282d3fb.zip llvm-2e26633af0c88ea23e3e8783ef60e621f282d3fb.tar.gz llvm-2e26633af0c88ea23e3e8783ef60e621f282d3fb.tar.bz2 |
[IR] document and update ctlz/cttz intrinsics to optionally return poison rather than undef
The behavior in Analysis (knownbits) implements poison semantics already,
and we expect the transforms (for example, in instcombine) derived from
those semantics, so this patch changes the LangRef and remaining code to
be consistent. This is one more step in removing "undef" from LLVM.
Without this, I think https://github.com/llvm/llvm-project/issues/53330
has a legitimate complaint because that report wants to allow subsequent
code to mask off bits, and that is allowed with undef values. The clang
builtins are not actually documented anywhere AFAICT, but we might want
to add that to remove more uncertainty.
Differential Revision: https://reviews.llvm.org/D117912
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 942dbe0..3435873 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1593,7 +1593,7 @@ static void computeKnownBitsFromOperator(const Operator *I, computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q); // If we have a known 1, its position is our upper bound. unsigned PossibleLZ = Known2.countMaxLeadingZeros(); - // If this call is undefined for 0, the result will be less than 2^n. + // If this call is poison for 0 input, the result will be less than 2^n. if (II->getArgOperand(1) == ConstantInt::getTrue(II->getContext())) PossibleLZ = std::min(PossibleLZ, BitWidth - 1); unsigned LowBits = Log2_32(PossibleLZ)+1; @@ -1604,7 +1604,7 @@ static void computeKnownBitsFromOperator(const Operator *I, computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q); // If we have a known 1, its position is our upper bound. unsigned PossibleTZ = Known2.countMaxTrailingZeros(); - // If this call is undefined for 0, the result will be less than 2^n. + // If this call is poison for 0 input, the result will be less than 2^n. if (II->getArgOperand(1) == ConstantInt::getTrue(II->getContext())) PossibleTZ = std::min(PossibleTZ, BitWidth - 1); unsigned LowBits = Log2_32(PossibleTZ)+1; |