SCEVExpander: Try hard not to create derived induction variables in other loops
authorArnold Schwaighofer <aschwaighofer@apple.com>
Sun, 16 Feb 2014 15:49:50 +0000 (15:49 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Sun, 16 Feb 2014 15:49:50 +0000 (15:49 +0000)
commit2ced33808ef63404372ce56a4856c768dae3deaa
tree16c9acdad6e653602c7225b3458b5b275c843bb8
parent56d34914b2351d9ba7951a0325ca7908617d5699
SCEVExpander: Try hard not to create derived induction variables in other loops

During LSR of one loop we can run into a situation where we have to expand the
start of a recurrence of a loop induction variable in this loop. This start
value is a value derived of the induction variable of a preceeding loop. SCEV
has cannonicalized this value to a different recurrence than the recurrence of
the preceeding loop's induction variable (the type and/or step direction) has
changed). When we come to instantiate this SCEV we created a second induction
variable in this preceeding loop.  This patch tries to base such derived
induction variables of the preceeding loop's induction variable.

This helps twolf on arm and seems to help scimark2 on x86.

Reapply with a fix for the case of a value derived from a pointer.

radar://15970709

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201496 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolutionExpander.h
lib/Analysis/ScalarEvolutionExpander.cpp
test/Transforms/LoopStrengthReduce/X86/no_superflous_induction_vars.ll [new file with mode: 0644]