[llvm] [DAGCombiner] Fix subvector extraction index for big-endian STLF (PR #180795)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 10:15:19 PST 2026
================
@@ -37,8 +37,11 @@ define <2 x bfloat> @shuffle_chained_v16bf16(<16 x bfloat> %a) {
; CHECK-NEXT: .cfi_def_cfa_register %rbp
; CHECK-NEXT: andq $-32, %rsp
; CHECK-NEXT: subq $96, %rsp
-; CHECK-NEXT: vmovdqa %ymm0, (%rsp)
+; CHECK-NEXT: vmovaps %ymm0, (%rsp)
+; CHECK-NEXT: vmovdqa (%rsp), %xmm0
; CHECK-NEXT: vpunpcklwd {{.*#+}} xmm0 = xmm0[0],mem[0],xmm0[1],mem[1],xmm0[2],mem[2],xmm0[3],mem[3]
+; CHECK-NEXT: vmovdqa %ymm0, {{[0-9]+}}(%rsp)
+; CHECK-NEXT: vmovaps {{[0-9]+}}(%rsp), %xmm0
----------------
Michael-Chen-NJU wrote:
> @phoebewang @KanRobert Are we just missing EXTRACT_SUBVECTOR legality for bf16 vectors causing isExtractSubvectorCheap to fail?
I've conducted a controlled experiment to isolate the cause of the X86 regression, and it confirms that the FrameIndex check is the sole blocker.
When I keep isExtractSubvectorCheap, remove FrameIndex check: The optimization works perfectly.
```
; CHECK-NEXT: vmovdqa64 %zmm0, (%rsp)
; CHECK-NEXT: vmovaps (%rsp), %xmm0
```
is replaced by a zero-cost:
```
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 killed $zmm0
```
And when I keep `FrameIndex` check, remove isExtractSubvectorCheap, The optimization is blocked, the redundant stack operations remain.
So the regression is purely due to the 'safety' check for infinite loops on FrameIndex. While this protects some targets, it's 'over-killing' valid STLF cases on X86 where the data just happens to be on the stack.
https://github.com/llvm/llvm-project/pull/180795
More information about the llvm-commits
mailing list