[llvm] [InstCombine] Invalidate changes to `DoesConsume` if the first try fails (PR #82973)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 09:08:30 PST 2024


================
@@ -2341,9 +2341,12 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
                   !shouldAvoidAbsorbingNotIntoSelect(*cast<SelectInst>(V));
   // Selects/min/max with invertible operands are freely invertible
   if (IsSelect || match(V, m_MaxOrMin(m_Value(A), m_Value(B)))) {
+    bool SaveDoesConsume = DoesConsume;
----------------
nikic wrote:

I'd personally invert this, and do `bool LocalDoesConsume = DoesConsume;`, pass that as the parameters and then do `DoesConsume = LocalDoesConsume` when it succeeds. I think that's less error-prone than restoring on the error paths.

https://github.com/llvm/llvm-project/pull/82973


More information about the llvm-commits mailing list