[PATCH] D139832: [IndVars] Support AND in optimizeLoopExitWithUnknownExitCount

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 22:18:27 PST 2022


mkazantsev added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1465
+  Value *NewCond = Builder.CreateAnd(Conditions);
+  replaceExitCond(BI, NewCond, DeadInsts);
   return true;
----------------
mkazantsev wrote:
> nikic wrote:
> > Why do we have to reconstruct the whole and chain? Can't we replace a single condition only? This looks quite fragile, especially as we probably want to generalize this to logical and as well, and at that point we'd have to replicate different types of ands in the correct position.
> It's only possible if no one else outside our cluster is using it. If they are, we can't simply replace operands of AND's.
> 
> One more (indirect, but still useful) effect of this algorithm is that it'll also eliminate duplicates, should they be in the AND tree.
> 
> As for logical AND -- what's the complexity? We keep conditions in the original order in `Conditions`, and replace them in the very same places. All it takes to support logical AND -- is to call another Builder function (multi-operand logical AND). If it doesn't exist, it's only a reason to write it.
"using them" I mean "using ANDs"


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139832/new/

https://reviews.llvm.org/D139832



More information about the llvm-commits mailing list