[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:46:36 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:
think the `Builder == nullptr` case should return `V` (which is equally valid as `NonNull`).
I see that it ends up working b.c the force of recursive depth to the end and `/*WillInvertAllUses=*/false` will make it only match `not`. But should be fixed up I think.
Not related to the current bug though.
https://github.com/llvm/llvm-project/pull/82973
More information about the llvm-commits
mailing list