ec54867df5e7 updated SCEV to epxand ASHR instructions to an
equivalent SCEV expression. This has the side effect that expanding
expressions based on ASHR instructions now expand to substantially
larger IR than before, which means the IndVarSimplify for example can
add a substantial amount of extra instructions when re-writing exit
conditions. This is causing ~5% regressions in some Geekbench
benchmarks.
This patch tries to match the SCEV expression created for ASHR during
expansion and emit an ASHR instruction directly. Note that currently
this pattern is not completely correct, because we have no way of
differentiating exact and non-exact UDivs in SCEV (see
the no_ashr_due_to_missing_exact_udiv test case, which generates ashr
incorrectly)! This needs to be resolved first and I'd appreciate any
feedback on the preferred direction.
Should we just add a flag to SCEVUDivExpr? Or mark UDivs as exact in a
separate table?
Note that there are other places using SCEVExpander where this likely
pessimizes the generated IR, e.g. when generating runtime checks for LV.
clang-tidy: warning: 'auto *SMin' can be declared as 'const auto *SMin' [llvm-qualified-auto]
not useful