[llvm] [InstCombine] Invalidate changes to `DoesConsume` if the first try fails (PR #82973)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 09:34:22 PST 2024
================
@@ -2307,9 +2309,11 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
// If `V` is of the form `A ^ ~B` then `~(A ^ ~B)` can be folded
// into `A ^ B` if we are willing to invert all of the uses.
if (match(V, m_Xor(m_Value(A), m_Value(B)))) {
+ bool DoesConsumeOldValue = DoesConsume;
if (auto *BV = getFreelyInvertedImpl(B, B->hasOneUse(), Builder,
DoesConsume, Depth))
return Builder ? Builder->CreateXor(A, BV) : NonNull;
+ DoesConsume = DoesConsumeOldValue;
if (auto *AV = getFreelyInvertedImpl(A, A->hasOneUse(), Builder,
DoesConsume, Depth))
return Builder ? Builder->CreateXor(AV, B) : NonNull;
----------------
goldsteinn wrote:
Still trying to properly understand why this is the fix, but something to note:
below at line:2377 seems buggy.
```
if (NewIncomingVal == V)
return nullptr;
```
`NewIncomingVal` uses `builder` as `nullptr` so if the return is non-null, it will return `NonNull` which will never equal `V`
https://github.com/llvm/llvm-project/pull/82973
More information about the llvm-commits
mailing list