]> granicus.if.org Git - llvm/commit
[InstCombine] fold sign-bit compares of srem
authorSanjay Patel <spatel@rotateright.com>
Wed, 11 Sep 2019 12:04:26 +0000 (12:04 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 11 Sep 2019 12:04:26 +0000 (12:04 +0000)
commit3813551fb7e0d34d90ad1370be914a4f042afcfb
treee92348b86489daa23fa4ea4f8cb2edcbe4871d4f
parent75f0bef615562d4ad92576642e0b38e658a90994
[InstCombine] fold sign-bit compares of srem

(srem X, pow2C) sgt/slt 0 can be reduced using bit hacks by masking
off the sign bit and the module (low) bits:
https://rise4fun.com/Alive/jSO
A '2' divisor allows slightly more folding:
https://rise4fun.com/Alive/tDBM

Any chance to remove an 'srem' use is probably worthwhile, but this is limited
to the one-use improvement case because doing more may expose other missing
folds. That means it does nothing for PR21929 yet:
https://bugs.llvm.org/show_bug.cgi?id=21929

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371610 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCompares.cpp
lib/Transforms/InstCombine/InstCombineInternal.h
test/Transforms/InstCombine/icmp-div-constant.ll