[InstCombine] Avoid ConstantExpr::getAnd() (NFCI)
authorNikita Popov <npopov@redhat.com>
Thu, 20 Jul 2023 12:17:07 +0000 (14:17 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 20 Jul 2023 12:20:49 +0000 (14:20 +0200)
In preparation for removing and constant expressions.

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

index d956d99..dbb33e8 100644 (file)
@@ -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,