[PATCH] D28406: [InstCombine] icmp sgt (shl nsw X, C1), C0 --> icmp sgt X, C0 >> C1
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 11:25:34 PST 2017
spatel added a comment.
In https://reviews.llvm.org/D28406#648394, @bryant wrote:
> This looks like the signed analogue of the unsigned case on line 1965. Since the unsigned case handles both ugt and ule (but makes the substitutions for ult), perhaps you could handle sle as well:
Sure - I was planning to expand this for sle (slt) and the missed eq/ne folds. It will make the code patch slightly bigger to handle sgt/sle in one step, but if that's preferred to match the existing code, I think it's ok.
To match LLVM's canonicalization to slt, I think the Alive code becomes:
Pre: C0 != -128
%a = shl nsw i8 %x, C1
%b = icmp slt %a, C0
%b = icmp slt %x, ((C0 - 1) >> C1) + 1
More information about the llvm-commits