[all-commits] [llvm/llvm-project] ffb2af: [SCEVExpander] Attempt to reinfer flags dropped du...
Philip Reames via All-commits
all-commits at lists.llvm.org
Thu Dec 7 13:20:49 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ffb2af3ed6a95a4eb55b81a3d1351d5d4bd66eb5
https://github.com/llvm/llvm-project/commit/ffb2af3ed6a95a4eb55b81a3d1351d5d4bd66eb5
Author: Philip Reames <preames at rivosinc.com>
Date: 2023-12-07 (Thu, 07 Dec 2023)
Changed paths:
M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
M llvm/test/CodeGen/RISCV/riscv-codegenprepare-asm.ll
M llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
M llvm/test/Transforms/IRCE/non-loop-invariant-rhs-instr.ll
M llvm/test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll
M llvm/test/Transforms/LoopPredication/basic.ll
M llvm/test/Transforms/LoopUnroll/runtime-exit-phi-scev-invalidation.ll
Log Message:
-----------
[SCEVExpander] Attempt to reinfer flags dropped due to CSE (#72431)
LSR uses SCEVExpander to generate induction formulas. The expander
internally tries to reuse existing IR expressions. To do that, it needs
to strip any poison generating flags (nsw, nuw, exact, nneg, etc..)
which may not be valid for the newly added users.
This is conservatively correct, but has the effect that LSR will strip
nneg flags on zext instructions involved in trip counts in loop
preheaders. To avoid this, this patch adjusts the expanded to reinfer
the flags on the CSE candidate if legal for all possible users.
This should fix the regression reported in
https://github.com/llvm/llvm-project/issues/71200.
This should arguably be done inside canReuseInstruction instead, but
doing it outside is more conservative compile time wise. Both
canReuseInstruction and isGuaranteedNotToBePoison walk operand lists, so
right now we are performing work which is roughly O(N^2) in the size of
the operand graph. We should fix that before making the per operand step
more expensive. My tenative plan is to land this, and then rework the
code to sink the logic into more core interfaces.
More information about the All-commits
mailing list