[InstCombine] Recommit: Fold (x << y) >> y -> x & (-1 >> y)
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 15 Jun 2018 09:56:52 +0000 (09:56 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 15 Jun 2018 09:56:52 +0000 (09:56 +0000)
commit84c11aed10eb809aa133da350071d82924bbdb23
tree483f4e5a0d5771435787a6637da92505329f45c2
parentdec562c84956d4816b168b1a7bfe7b2703eaaf86
[InstCombine] Recommit: Fold  (x << y) >> y  ->  x & (-1 >> y)

Summary:
We already do it for splat constants, but not just values.
Also, undef cases are mostly non-functional.

The original commit was reverted because
it broke tests for amdgpu backend, which i didn't check.
Now, the backed was updated to recognize these new
patterns, so we are good.

https://bugs.llvm.org/show_bug.cgi?id=37603
https://rise4fun.com/Alive/cplX

Reviewers: spatel, craig.topper, mareko, bogner, rampitec, nhaehnle, arsenm

Reviewed By: spatel, rampitec, nhaehnle

Subscribers: wdng, nhaehnle, llvm-commits

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

llvm-svn: 334818
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll