[llvm] b66220f - [InstCombine] [NFC] use C.isNegatedPowerOf2() instead of (~C + 1).isPowerOf2()

Chenbing Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 5 02:05:26 PDT 2022


Author: Chenbing Zheng
Date: 2022-07-05T17:04:59+08:00
New Revision: b66220f25aead4043208ef2fb1c33acd161d666a

URL: https://github.com/llvm/llvm-project/commit/b66220f25aead4043208ef2fb1c33acd161d666a
DIFF: https://github.com/llvm/llvm-project/commit/b66220f25aead4043208ef2fb1c33acd161d666a.diff

LOG: [InstCombine] [NFC] use C.isNegatedPowerOf2() instead of (~C + 1).isPowerOf2()

Reviewed By: RKSimon

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

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d1f89973caa1..49951d19b0c3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1779,7 +1779,7 @@ Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp,
 
     // Restrict this fold only for single-use 'and' (PR10267).
     // ((%x & C) == 0) --> %x u< (-C)  iff (-C) is power of two.
-    if ((~(*C2) + 1).isPowerOf2()) {
+    if (C2->isNegatedPowerOf2()) {
       Constant *NegBOC =
           ConstantExpr::getNeg(cast<Constant>(And->getOperand(1)));
       auto NewPred = isICMP_NE ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT;


        


More information about the llvm-commits mailing list