[PowerPC] Fix LoopPreIncPrep not to depend on SCEV constant simplifications
authorHal Finkel <hfinkel@anl.gov>
Sun, 8 Nov 2015 08:04:40 +0000 (08:04 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 8 Nov 2015 08:04:40 +0000 (08:04 +0000)
commit455a0bcfcce8a12503a3029d4d7c4469a5b0c74c
treeacf13704ad5a27eefe6c6653ce380f8c9ab445fd
parent08a70b0f2bedd2efefb9e6fe18982082bdef72db
[PowerPC] Fix LoopPreIncPrep not to depend on SCEV constant simplifications

Under most circumstances, if SCEV can simplify X-Y to a constant, then it can
also simplify Y-X to a constant. However, there is no guarantee that this is
always true, and concensus is not to consider that a correctness bug in SCEV
(although it is undesirable).

PPCLoopPreIncPrep gathers pointers used to access memory (via loads, stores and
prefetches) into buckets, where in each bucket the relative pointer offsets are
constant. We used to keep each bucket as a multimap, where SCEV's subtraction
operation was used to define the ordering predicate. Instead, use a fixed SCEV
base expression for each bucket, record the constant offsets from that base
expression, and adjust it later, if desirable, once all pointers have been
collected.

Doing it this way should be more compile-time efficient than the previous
scheme (in addition to making the implementation less sensitive to SCEV
simplification quirks).

Fixes PR25170.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252417 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCLoopPreIncPrep.cpp
test/CodeGen/PowerPC/preincprep-nontrans-crash.ll [new file with mode: 0644]