[InstCombine] Fold srem(X, PowerOf2) == C into (X & Mask) == C for positive C
authorAlexander Shaposhnikov <ashaposhnikov@google.com>
Sun, 3 Apr 2022 03:57:05 +0000 (03:57 +0000)
committerAlexander Shaposhnikov <ashaposhnikov@google.com>
Sun, 3 Apr 2022 03:57:05 +0000 (03:57 +0000)
commit6cf10b7e6e839fea1843ba365a6a26e77b52e251
tree01730b91f5ba82751f956d1307b42bd506a3e766
parent911cfcd7f591b945369de3fca37dace71ae6054d
[InstCombine] Fold srem(X, PowerOf2) == C into (X & Mask) == C for positive C

This diff extends InstCombinerImpl::foldICmpSRemConstant to handle the cases
srem(X, PowerOf2) == C and
srem(X, PowerOf2) != C
for positive C.
This addresses the issue https://github.com/llvm/llvm-project/issues/54650

Differential revision: https://reviews.llvm.org/D122942

Test plan: make check-all
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/rem.ll