Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
authorSilviu Baranga <silviu.baranga@arm.com>
Fri, 8 Apr 2016 14:29:09 +0000 (14:29 +0000)
committerSilviu Baranga <silviu.baranga@arm.com>
Fri, 8 Apr 2016 14:29:09 +0000 (14:29 +0000)
commit6f444dfd5517d03a750918eaee4ef9f82a11c268
treea1011268d57c4ccf1cc01fd74152758c0c6bd524
parent476170384fa92eaf1258f784709b6907041d313a
Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV

This re-commits r265535 which was reverted in r265541 because it
broke the windows bots. The problem was that we had a PointerIntPair
which took a pointer to a struct allocated with new. The problem
was that new doesn't provide sufficient alignment guarantees.
This pattern was already present before r265535 and it just happened
to work. To fix this, we now separate the PointerToIntPair from the
ExitNotTakenInfo struct into a pointer and a bool.

Original commit message:

Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D17201

llvm-svn: 265786
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Analysis/ScalarEvolution/predicated-trip-count.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/AArch64/backedge-overflow.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll