[llvm] [X86] combineKSHIFT - fold kshiftr(kshiftr/extract_subvector(X, C1), C2) --> kshiftr(X, C1+C2) (PR #115528)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 9 08:21:19 PST 2024


================
@@ -58405,11 +58405,30 @@ static SDValue combineEXTEND_VECTOR_INREG(SDNode *N, SelectionDAG &DAG,
 static SDValue combineKSHIFT(SDNode *N, SelectionDAG &DAG,
                              TargetLowering::DAGCombinerInfo &DCI) {
   EVT VT = N->getValueType(0);
-
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   if (ISD::isBuildVectorAllZeros(N->getOperand(0).getNode()))
     return DAG.getConstant(0, SDLoc(N), VT);
 
-  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  // Fold kshiftr(extract_subvector(X,C1),C2)
+  //  --> extract_subvector(kshiftr(X,C1+C2),0)
+  // Fold kshiftr(kshiftr(X,C1),C2) --> kshiftr(X,C1+C2)
----------------
RKSimon wrote:

`(kshiftl (kshiftl x, c1), c2)` might be useful - not sure if we need to support `kshiftl+insert_subvector/concat_subvectors` patterns or not though.

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


More information about the llvm-commits mailing list