[llvm] [PowerPC] Optimize vector compares not equal to non-zero elements (PR #174361)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 01:09:31 PST 2026


================
@@ -19471,6 +19475,53 @@ SDValue PPCTargetLowering::combineADD(SDNode *N, DAGCombinerInfo &DCI) const {
   return SDValue();
 }
 
+// The following transformation is meant to optimize vector compares not equal
+// to non-zeros Ex: vec[i] != 7, where vec is a vector and the comparison is
+// element non-zero number. (and (anyext (setcc A, B, SETNE)), splat32(1))
+//  -> (zext (add (setcc A, B, SETEQ), splat16(1)))
+SDValue
+PPCTargetLowering::combineVectorZExtCompare(SDNode *N,
+                                            DAGCombinerInfo &DCI) const {
+  if (!Subtarget.hasVSX() || N->getOpcode() != ISD::AND)
+    return SDValue();
+
+  SelectionDAG &DAG = DCI.DAG;
+  SDLoc DL(N);
+  EVT VT = N->getValueType(0);
+  SDValue Op0 = N->getOperand(0);
+  SDValue Op1 = N->getOperand(1);
+
+  APInt SplatVal;
+  if (!ISD::isConstantSplatVector(Op1.getNode(), SplatVal) || SplatVal != 1)
----------------
Himadhith wrote:

done

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


More information about the llvm-commits mailing list