OSDN Git Service

Re-enable "[SCEV] Do not fold dominated SCEVUnknown into AddRecExpr start"
authorMax Kazantsev <max.kazantsev@azul.com>
Fri, 26 May 2017 06:47:04 +0000 (06:47 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Fri, 26 May 2017 06:47:04 +0000 (06:47 +0000)
commit96c95e627d65564630b7d4b936633e97fd7cfcc5
tree634ce39da44bcc0c1dc57c341dc64870864e8be9
parentb0e29ac6a689c6551b2c9c854b95ebaf5f1a2c3a
Re-enable "[SCEV] Do not fold dominated SCEVUnknown into AddRecExpr start"

The patch rL303730 was reverted because test lsr-expand-quadratic.ll failed on
many non-X86 configs with this patch. The reason of this is that the patch
makes a correctless fix that changes optimizer's behavior for this test.
Without the change, LSR was making an overconfident simplification basing on a
wrong SCEV. Apparently it did not need the IV analysis to do this. With the
change, it chose a different way to simplify (that wasn't so confident), and
this way required the IV analysis. Now, following the right execution path,
LSR tries to make a transformation relying on IV Users analysis. This analysis
is target-dependent due to this code:

  // LSR is not APInt clean, do not touch integers bigger than 64-bits.
  // Also avoid creating IVs of non-native types. For example, we don't want a
  // 64-bit IV in 32-bit code just because the loop has one 64-bit cast.
  uint64_t Width = SE->getTypeSizeInBits(I->getType());
  if (Width > 64 || !DL.isLegalInteger(Width))
    return false;

To make a proper transformation in this test case, the type i32 needs to be
legal for the specified data layout. When the test runs on some non-X86
configuration (e.g. pure ARM 64), opt gets confused by the specified target
and does not use it, rejecting the specified data layout as well. Instead,
it uses some default layout that does not treat i32 as a legal type
(currently the layout that is used when it is not specified does not have
legal types at all). As result, the transformation we expect to happen does
not happen for this test.

This re-enabling patch does not have any source code changes compared to the
original patch rL303730. The only difference is that the failing test is
moved to X86 directory and now has requirement of running on x86 only to comply
with the specified target triple and data layout.

Differential Revision: https://reviews.llvm.org/D33543

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303971 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Analysis/IVUsers/quadradic-exit-value.ll
test/Analysis/ScalarEvolution/different-loops-recs.ll
test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll
test/Transforms/LoopStrengthReduce/X86/lsr-expand-quadratic.ll [moved from test/Transforms/LoopStrengthReduce/lsr-expand-quadratic.ll with 51% similarity]
test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll