[SCEV] Apply NSW and NUW flags via poison value analysis for sub, mul and shl
authorBjarke Hammersholt Roune <broune@google.com>
Fri, 14 Aug 2015 22:45:26 +0000 (22:45 +0000)
committerBjarke Hammersholt Roune <broune@google.com>
Fri, 14 Aug 2015 22:45:26 +0000 (22:45 +0000)
commit0498bd2ae808eacd7b128bb70a3c18c2308a3730
treee1a8344e3e53740f759546192779664dcd15ac5a
parent08f721d1dea00dadb3242883e249b51054dd7452
[SCEV] Apply NSW and NUW flags via poison value analysis for sub, mul and shl

Summary:
http://reviews.llvm.org/D11212 made Scalar Evolution able to propagate NSW and NUW flags from instructions to SCEVs for add instructions. This patch expands that to sub, mul and shl instructions.

This change makes LSR able to generate pointer induction variables for loops like these, where the index is 32 bit and the pointer is 64 bit:

  for (int i = 0; i < numIterations; ++i)
    sum += ptr[i - offset];

  for (int i = 0; i < numIterations; ++i)
    sum += ptr[i * stride];

  for (int i = 0; i < numIterations; ++i)
    sum += ptr[3 * (i << 7)];

Reviewers: atrick, sanjoy

Subscribers: sanjoy, majnemer, hfinkel, llvm-commits, meheff, jingyue, eliben

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245118 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Analysis/Delinearization/a.ll
test/Analysis/ScalarEvolution/flags-from-poison.ll
test/Analysis/ScalarEvolution/min-max-exprs.ll
test/Transforms/LoopStrengthReduce/sext-ind-var.ll