You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[GVN] Load-store forwaring of scalable store to fixed load.
When storing a scalable vector and the vscale is a compile-time known
constant, store-to-load forwarding through temporary
@llvm.vector.extract calls, even if the loaded vector is fixed-sized
instead of scalable. InstCombine then folds the insert/extract pair
away.
The usecase is shown in this [godbold
link](https://godbolt.org/z/KT3sMrMbd), which shows that clang generates
IR that matches this pattern when the "arm_sve_vector_bits" attribute is
used:
```c
typedef svfloat32_t svfloat32_fixed_t
__attribute__((arm_sve_vector_bits(512)));
struct svfloat32_wrapped_t {
svfloat32_fixed_t v;
};
static inline svfloat32_wrapped_t
add(svfloat32_wrapped_t a, svfloat32_wrapped_t b) {
return {svadd_f32_x(svptrue_b32(), a.v, b.v)};
}
svfloat32_wrapped_t
foo(svfloat32_wrapped_t a, svfloat32_wrapped_t b) {
// The IR pattern this patch matches is generated for this return:
return add(a, b);
}
```
; CHECK-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v16f32(<vscale x 4 x float> poison, <16 x float> [[TMP1]], i64 0)
653
-
; CHECK-NEXT: ret <vscale x 4 x float> [[CAST_SCALABLE]]
651
+
; CHECK-NEXT: ret <vscale x 4 x float> [[TMP0]]
654
652
;
655
653
entry:
656
654
%retval = alloca { <16 x float> }
@@ -667,9 +665,7 @@ define <vscale x 4 x float> @scalable_store_to_fixed_load_only_lower_bound(<vsca
667
665
; CHECK-NEXT: entry:
668
666
; CHECK-NEXT: [[RETVAL:%.*]] = alloca { <vscale x 4 x float> }, align 16
669
667
; CHECK-NEXT: store <vscale x 4 x float> [[A:%.*]], ptr [[RETVAL]], align 16
; CHECK-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v16f32(<vscale x 4 x float> poison, <16 x float> [[TMP0]], i64 0)
672
-
; CHECK-NEXT: ret <vscale x 4 x float> [[CAST_SCALABLE]]
668
+
; CHECK-NEXT: ret <vscale x 4 x float> [[A]]
673
669
;
674
670
entry:
675
671
%retval = alloca { <vscale x 4 x float> }
@@ -760,7 +756,7 @@ define <4 x float> @scalable_store_to_small_fixed_load(<vscale x 4 x float> %a)
760
756
; CHECK-NEXT: entry:
761
757
; CHECK-NEXT: [[PTR:%.*]] = alloca <vscale x 4 x float>, align 16
762
758
; CHECK-NEXT: store <vscale x 4 x float> [[A:%.*]], ptr [[PTR]], align 16
0 commit comments