[llvm] cdab611 - [InstCombine] Avoid ConstantExpr::getAnd() (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 05:20:57 PDT 2023


Author: Nikita Popov
Date: 2023-07-20T14:20:49+02:00
New Revision: cdab6116eba92ce27d780d43e14a7ca15b972e7b

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

LOG: [InstCombine] Avoid ConstantExpr::getAnd() (NFCI)

In preparation for removing and constant expressions.

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 d956d99fb2ba83..dbb33e89359fa4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -199,7 +199,11 @@ Instruction *InstCombinerImpl::foldCmpLoadFromIndexedGlobal(
     }
 
     // If the element is masked, handle it.
-    if (AndCst) Elt = ConstantExpr::getAnd(Elt, AndCst);
+    if (AndCst) {
+      Elt = ConstantFoldBinaryOpOperands(Instruction::And, Elt, AndCst, DL);
+      if (!Elt)
+        return nullptr;
+    }
 
     // Find out if the comparison would be true or false for the i'th element.
     Constant *C = ConstantFoldCompareInstOperands(ICI.getPredicate(), Elt,


        


More information about the llvm-commits mailing list