[llvm] [DAG] Fold extract_subvector(insert_subvector(x, y, c1), c2) --> extract_subvector(y,c2-c1) (PR #87925)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 7 18:08:19 PDT 2024
================
@@ -24459,6 +24459,23 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
if (!LegalOperations || TLI.isOperationLegal(ISD::SPLAT_VECTOR, NVT))
return DAG.getSplatVector(NVT, SDLoc(N), V.getOperand(0));
+ // extract_subvector(insert_subvector(x,y,c1),c2)
+ // --> extract_subvector(y,c2-c1)
----------------
phoebewang wrote:
The `c1`, `c2` are indices based on type of `y` and `NVT`, we cannot sub them directly given they have difference scale.
For example, if we insert `v16i8` to `v32i8` at index 1, then extra `v8i8` at index 2.
```
| v16i8(y)| v16i8 |
|v8i8| NVT|v8i8|v8i8|
```
The new index is `c2 - c1 * (NumInsElts/NumSubElts) = 0` instead of `c2 - c1 = 1`.
https://github.com/llvm/llvm-project/pull/87925
More information about the llvm-commits
mailing list