forked from OSchip/llvm-project
![]() rGf39978b84f1d3a1da6c32db48f64c8daae64b3ad led to and/or exposed an issue with IndVarSimplification for a loop where a i32 phi node is no longer replaced by a widened (i64) phi node, because the SCEVs of a sign-extend no longer folded the same way. I'm unsure how to properly explain this because it's all rather complicated, but in short: SCEVs don't fold as nicely as they used to and this caused a difference. While investigating this, I found that IndVarSimplify can actually optimise the case in the way we want to if it chooses the widened IV to be 'signed' (the i32 IV is both sign and zero-extended). Oddly enough, there is some level of indeterminism in the way the algorithm works, it just picks the sign of the 'first' zext/sext user, where the order of the users-iterator is not guaranteed to be the same on each invocation of the pass (e.g. shown by first running loop-rotate, which puts the users in a different order). While I think the fix is valid in the sense that consistently picking _any_ order is better than having an nondeterministic order, I can use a bit of advice from people more familiar in this area of the code-base. For example, I'm not sure if this fix is hiding another issue where the IndVarSimplify pass could actually draw the same conclusions (i.e. that it only needs an i64 phi node) if it does a bit more work, regardless of whether it chooses the induction variable to be signed or unsigned. I'm also not sure if choosing signed is better than unsigned, or whether that just happens to be beneficial only in this individual case. Any feedback would be much appreciated! Reviewed By: reames Differential Revision: https://reviews.llvm.org/D112573 |
||
---|---|---|
.. | ||
AArch64 | ||
AMDGPU | ||
ARM | ||
NVPTX | ||
X86 | ||
2002-09-09-PointerIndVar.ll | ||
2003-04-16-ExprAnalysis.ll | ||
2003-09-23-NotAtTop.ll | ||
2003-12-10-RemoveInstrCrash.ll | ||
2003-12-15-Crash.ll | ||
2004-03-10-PHIInsertionBug.ll | ||
2004-04-05-InvokeCastCrash.ll | ||
2004-04-07-ScalarEvolutionCrash.ll | ||
2005-02-11-InvokeCrash.ll | ||
2005-02-17-TruncateExprCrash.ll | ||
2005-02-26-ExitValueCompute.ll | ||
2005-06-15-InstMoveCrash.ll | ||
2005-11-18-Crash.ll | ||
2006-03-31-NegativeStride.ll | ||
2006-06-16-Indvar-LCSSA-Crash.ll | ||
2006-09-20-LFTR-Crash.ll | ||
2006-12-10-BitCast.ll | ||
2007-01-06-TripCount.ll | ||
2007-06-06-DeleteDanglesPtr.ll | ||
2007-11-23-BitcastCrash.ll | ||
2008-06-15-SCEVExpanderBug.ll | ||
2008-09-02-IVType.ll | ||
2008-10-03-CouldNotCompute.ll | ||
2008-11-25-APFloatAssert.ll | ||
2009-04-22-IndvarCrash.ll | ||
2009-04-27-Floating.ll | ||
2009-05-24-useafterfree.ll | ||
2011-09-10-widen-nsw.ll | ||
2011-09-19-vectoriv.ll | ||
2011-09-27-hoistsext.ll | ||
2011-10-27-lftrnull.ll | ||
2011-11-01-lftrptr.ll | ||
2011-11-17-selfphi.ll | ||
2012-10-19-congruent-constant.ll | ||
2014-06-21-congruent-constant.ll | ||
2020-12-15-trunc-bug-expensive-range-inference.ll | ||
D108043.ll | ||
ada-loops.ll | ||
addrec_no_exec_on_every_iteration.ll | ||
ashr-expansion.ll | ||
ashr-tripcount.ll | ||
avoid-i0.ll | ||
backedge-on-min-max.ll | ||
bec-cmp.ll | ||
canonicalize-cmp.ll | ||
casted-argument.ll | ||
checks_against_min_value.ll | ||
const_phi.ll | ||
constant-fold.ll | ||
constant_result.ll | ||
crash.ll | ||
dangling-use.ll | ||
deterministic-sign.ll | ||
divide-pointer.ll | ||
dont-recompute.ll | ||
drop-exact.ll | ||
elim-extend.ll | ||
eliminate-backedge.ll | ||
eliminate-comparison.ll | ||
eliminate-exit-no-dl.ll | ||
eliminate-exit.ll | ||
eliminate-max.ll | ||
eliminate-overflow-modified.ll | ||
eliminate-rem.ll | ||
eliminate-sat.ll | ||
exit_value_test2.ll | ||
exit_value_test3.ll | ||
exit_value_tests.ll | ||
finite-exit-comparisons.ll | ||
floating-point-iv.ll | ||
full_widening.ll | ||
indirectbr.ll | ||
infer-poison-flags.ll | ||
interesting-invoke-use.ll | ||
invalidate-modified-lcssa-phi.ll | ||
iterationCount_zext_or_trunc.ll | ||
iv-fold.ll | ||
iv-sext.ll | ||
iv-widen-elim-ext.ll | ||
iv-zext.ll | ||
lcssa-preservation.ll | ||
lftr-address-space-pointers.ll | ||
lftr-dead-ivs.ll | ||
lftr-multi-exit.ll | ||
lftr-pr20680.ll | ||
lftr-pr31181.ll | ||
lftr-pr41998.ll | ||
lftr-promote.ll | ||
lftr-reuse.ll | ||
lftr.ll | ||
lftr_disabled.ll | ||
loop-predication.ll | ||
loop_evaluate7.ll | ||
loop_evaluate8.ll | ||
loop_evaluate9.ll | ||
loop_evaluate11.ll | ||
loop_evaluate_1.ll | ||
loop_evaluate_2.ll | ||
loop_evaluate_3.ll | ||
loop_evaluate_4.ll | ||
loop_evaluate_5.ll | ||
loop_evaluate_6.ll | ||
lrev-existing-umin.ll | ||
masked-iv.ll | ||
monotonic_checks.ll | ||
negative_ranges.ll | ||
no-iv-rewrite.ll | ||
outer_phi.ll | ||
phi-uses-value-multiple-times.ll | ||
post-inc-range.ll | ||
pr18223.ll | ||
pr22222.ll | ||
pr24783.ll | ||
pr24952.ll | ||
pr25060.ll | ||
pr25578.ll | ||
pr26974.ll | ||
pr28705.ll | ||
pr32045.ll | ||
pr38674.ll | ||
pr38855.ll | ||
pr39673.ll | ||
pr40454.ll | ||
pr45835.ll | ||
predicated_ranges.ll | ||
preserve-memoryssa.ll | ||
preserve-signed-wrap.ll | ||
promote-iv-to-eliminate-casts.ll | ||
replace-loop-exit-folds.ll | ||
replace-sdiv-by-udiv.ll | ||
replace-srem-by-urem.ll | ||
rewrite-loop-exit-value.ll | ||
rewrite-loop-exit-values-phi.ll | ||
rlev-add-me.ll | ||
scev-expander-preserve-lcssa.ll | ||
scevexpander-phi-base-case.ll | ||
sentinel.ll | ||
shared-exit-between-nested-loop.ll | ||
sharpen-range.ll | ||
shrunk-constant.ll | ||
signed-trip-count.ll | ||
simplify-pointer-arithmetic.ll | ||
single-element-range.ll | ||
sink-alloca.ll | ||
sink-from-preheader.ll | ||
sink-trapping.ll | ||
strengthen-overflow.ll | ||
tripcount_compute.ll | ||
tripcount_infinite.ll | ||
trivial-checks.ll | ||
trivial-guard.ll | ||
udiv-invariant-but-traps.ll | ||
udiv.ll | ||
ult-sub-to-eq.ll | ||
use-range-metadata.ll | ||
variable-stride-ivs-0.ll | ||
widen-i32-i8ptr.ll | ||
zext-nuw.ll |