[llvm] [DAG] select m, sub/add(X, C), X --> sub/add (X, and(C, m)) (PR #82441)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 24 10:37:56 PST 2024


================
@@ -11660,6 +11660,24 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
     }
   }
 
+  // select m, sub(X, C), X --> sub (X, and(C, m))
+  if (N1.getOpcode() == ISD::SUB && N1.getOperand(0) == N2 && N1->hasOneUse() &&
+      DAG.isConstantIntBuildVectorOrConstantInt(N1.getOperand(1)) &&
+      N0.getScalarValueSizeInBits() == N1.getScalarValueSizeInBits()) {
----------------
goldsteinn wrote:

Shouldn't `sext` guarantee that?

https://github.com/llvm/llvm-project/pull/82441


More information about the llvm-commits mailing list