[InstCombine] Fold a shifty implementation of clamp-to-zero.
authorHuihui Zhang <huihuiz@quicinc.com>
Tue, 24 Sep 2019 00:15:03 +0000 (00:15 +0000)
committerHuihui Zhang <huihuiz@quicinc.com>
Tue, 24 Sep 2019 00:15:03 +0000 (00:15 +0000)
commit895219971592f7011083de395308a0702f911cb9
tree7feace8632d7b049b1047a38bbbc407ae368480f
parentadec1209e627aecb6634edb46e99e741d95ba95f
[InstCombine] Fold a shifty implementation of clamp-to-zero.

Summary:
Fold
and(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X)
into
X s> Y ? X : 0

https://rise4fun.com/Alive/lFH

Fold shift into select enables more optimization,
e.g., vmax generation for ARM target.

Reviewers: lebedev.ri, efriedma, spatel, kparzysz, bcahoon

Reviewed By: lebedev.ri

Subscribers: xbolva00, andreadb, craig.topper, RKSimon, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372676
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/sub-ashr-and-to-icmp-select.ll