Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs"
authorDmitry Makogon <d.makogon@g.nsu.ru>
Tue, 9 Nov 2021 09:51:41 +0000 (16:51 +0700)
committerDmitry Makogon <d.makogon@g.nsu.ru>
Tue, 9 Nov 2021 10:42:29 +0000 (17:42 +0700)
commit5ec23863320ca12bfabb6dcff1d0425cb614b7a5
treedea3aa2248ba2c59eb9afc7dea72600d16578622
parentacbefbf19f6c41854cca2e7df6507b345c502ec6
Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs"

This reapplies patch db289340c841990055a164e8eb2a3b5ff25677bf.

The test failures on build with expensive checks caused by the patch happened due
to the fact that we sorted loop Phis in replaceCongruentIVs using llvm::sort,
which shuffles the given container if the expensive checks are enabled,
so equivalent Phis in the sorted vector had different mutual order from run
to run. replaceCongruentIVs tries to replace narrow Phis with truncations
of wide ones. In some test cases there were several Phis with the same
width, so if their order differs from run to run, the narrow Phis would
be replaced with a different Phi, depending on the shuffling result.

The patch ae14fae0ff4304022beda5ab484f84ac0fdda807 fixed this issue by
replacing llvm::sort with llvm::stable_sort.
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/GVN/gvn-eliminate-duplicating-phis.ll
llvm/test/Transforms/IndVarSimplify/X86/pr27133.ll
llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll
llvm/test/Transforms/PhaseOrdering/X86/pixel-splat.ll
llvm/test/Transforms/PhaseOrdering/X86/vdiv.ll