OSDN Git Service

indvars: Linear function test replace should avoid reusing undef.
authorAndrew Trick <atrick@apple.com>
Wed, 18 Jul 2012 04:35:10 +0000 (04:35 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 18 Jul 2012 04:35:10 +0000 (04:35 +0000)
commit4781d8ee1cd586bf7a569f80e1e49694c93eddd8
treeddd01788c164c6fd412f657aacebdcfb26478e31
parent75dc33a60b65bbbf2253b0b916df1d36a4da4237
indvars: Linear function test replace should avoid reusing undef.

Fixes PR13371: indvars pass incorrectly substitutes 'undef' values.

I do not like this fix. It's needed until/unless the meaning of undef
changes. It attempts to be complete according to the IR spec, but I
don't have much confidence in the implementation given the difficulty
testing undefined behavior. Worse, this invalidates some of my
hard-fought work on indvars and LSR to optimize pointer induction
variables. It results benchmark regressions, which I'll track
internally. On x86_64 no LTO I see:

-3% huffbench
-3% 400.perlbench
-8% fhourstones

My only suggestion for recovering is to change the meaning of
undef. If we could trust an arbitrary instruction to produce a some
real value that can be manipulated (e.g. incremented) according to
non-undef rules, then this case could be easily handled with SCEV.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160421 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/2012-07-17-lftr-undef.ll [new file with mode: 0644]
test/Transforms/IndVarSimplify/lftr-reuse.ll