Teach getZeroExtendExpr and getSignExtendExpr to use trip-count
commita9dba968259e1bf3c400d2578cda0def65800923
authorDan Gohman <gohman@apple.com>
Mon, 27 Apr 2009 20:16:15 +0000 (27 20:16 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 27 Apr 2009 20:16:15 +0000 (27 20:16 +0000)
tree95d2dd1b8018daf6d158d81191912652e7b8e41d
parentfe9f9c1ae3a9dd8a0ea4ce35944d7779aaac58d2
Teach getZeroExtendExpr and getSignExtendExpr to use trip-count
information to simplify [sz]ext({a,+,b}) to {zext(a),+,[zs]ext(b)},
as appropriate.

These functions and the trip count code each call into the other, so
this requires careful handling to avoid infinite recursion. During
the initial trip count computation, conservative SCEVs are used,
which are subsequently discarded once the trip count is actually
known.

Among other benefits, this change lets LSR automatically eliminate
some unnecessary zext-inreg and sext-inreg operation where the
operand is an induction variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70241 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/CodeGen/X86/masked-iv-safe.ll [new file with mode: 0644]
test/CodeGen/X86/masked-iv-unsafe.ll [new file with mode: 0644]
test/Transforms/LoopStrengthReduce/change-compare-stride-trickiness-1.ll