[SCEV] Simplify zext/trunc idiom that appears when handling bitmasks.
authorJustin Lebar <jlebar@google.com>
Thu, 14 Jun 2018 17:13:48 +0000 (17:13 +0000)
committerJustin Lebar <jlebar@google.com>
Thu, 14 Jun 2018 17:13:48 +0000 (17:13 +0000)
commitfe455464eb1702653e8b835a79f03c48007c5a19
tree9a3070fe47df93af64254be7df4dd64b3d814e69
parentb326904dba986560d5d27da8bd67b963a14079b3
[SCEV] Simplify zext/trunc idiom that appears when handling bitmasks.

Summary:
Specifically, we transform

  zext(2^K * (trunc X to iN)) to iM ->
  2^K * (zext(trunc X to i{N-K}) to iM)<nuw>

This is helpful because pulling the 2^K out of the zext allows further
optimizations.

Reviewers: sanjoy

Subscribers: hiraditya, llvm-commits, timshen

Differential Revision: https://reviews.llvm.org/D48158

llvm-svn: 334737
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll
llvm/test/Analysis/ScalarEvolution/and-xor.ll