Skip to content

Commit 1343f8f

Browse files
committed
[GVN] Tests for load-store forwaring of scalable store to fixed load
1 parent c0861e9 commit 1343f8f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

llvm/test/Transforms/GVN/vscale.ll

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,65 @@ entry:
641641
call void @llvm.lifetime.end.p0(i64 -1, ptr nonnull %ref.tmp)
642642
ret { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } %15
643643
}
644+
645+
define <vscale x 4 x float> @scalable_store_to_fixed_load(<vscale x 4 x float> %.coerce) #1 {
646+
; CHECK-LABEL: @scalable_store_to_fixed_load(
647+
; CHECK-NEXT: entry:
648+
; CHECK-NEXT: [[RETVAL:%.*]] = alloca { <16 x float> }, align 64
649+
; CHECK-NEXT: [[TMP0:%.*]] = fadd <vscale x 4 x float> [[DOTCOERCE:%.*]], [[DOTCOERCE]]
650+
; CHECK-NEXT: store <vscale x 4 x float> [[TMP0]], ptr [[RETVAL]], align 16
651+
; CHECK-NEXT: [[TMP1:%.*]] = load <16 x float>, ptr [[RETVAL]], align 64
652+
; 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]]
654+
;
655+
entry:
656+
%retval = alloca { <16 x float> }
657+
%0 = fadd <vscale x 4 x float> %.coerce, %.coerce
658+
store <vscale x 4 x float> %0, ptr %retval
659+
%1 = load <16 x float>, ptr %retval
660+
%cast.scalable = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v16f32(<vscale x 4 x float> poison, <16 x float> %1, i64 0)
661+
ret <vscale x 4 x float> %cast.scalable
662+
}
663+
664+
define <vscale x 4 x float> @scalable_store_to_fixed_load_unknon_vscale(<vscale x 4 x float> %.coerce) {
665+
; CHECK-LABEL: @scalable_store_to_fixed_load_unknon_vscale(
666+
; CHECK-NEXT: entry:
667+
; CHECK-NEXT: [[RETVAL:%.*]] = alloca { <16 x float> }, align 64
668+
; CHECK-NEXT: [[TMP0:%.*]] = fadd <vscale x 4 x float> [[DOTCOERCE:%.*]], [[DOTCOERCE]]
669+
; CHECK-NEXT: store <vscale x 4 x float> [[TMP0]], ptr [[RETVAL]], align 16
670+
; CHECK-NEXT: [[TMP1:%.*]] = load <16 x float>, ptr [[RETVAL]], align 64
671+
; 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)
672+
; CHECK-NEXT: ret <vscale x 4 x float> [[CAST_SCALABLE]]
673+
;
674+
entry:
675+
%retval = alloca { <16 x float> }
676+
%0 = fadd <vscale x 4 x float> %.coerce, %.coerce
677+
store <vscale x 4 x float> %0, ptr %retval
678+
%1 = load <16 x float>, ptr %retval
679+
%cast.scalable = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v16f32(<vscale x 4 x float> poison, <16 x float> %1, i64 0)
680+
ret <vscale x 4 x float> %cast.scalable
681+
}
682+
683+
define <vscale x 4 x float> @scalable_store_to_fixed_load_size_missmatch(<vscale x 4 x float> %.coerce) #1 {
684+
; CHECK-LABEL: @scalable_store_to_fixed_load_size_missmatch(
685+
; CHECK-NEXT: entry:
686+
; CHECK-NEXT: [[RETVAL:%.*]] = alloca { <32 x float> }, align 128
687+
; CHECK-NEXT: [[TMP0:%.*]] = fadd <vscale x 4 x float> [[DOTCOERCE:%.*]], [[DOTCOERCE]]
688+
; CHECK-NEXT: store <vscale x 4 x float> [[TMP0]], ptr [[RETVAL]], align 16
689+
; CHECK-NEXT: [[TMP1:%.*]] = load <32 x float>, ptr [[RETVAL]], align 128
690+
; CHECK-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v32f32(<vscale x 4 x float> poison, <32 x float> [[TMP1]], i64 0)
691+
; CHECK-NEXT: ret <vscale x 4 x float> [[CAST_SCALABLE]]
692+
;
693+
entry:
694+
%retval = alloca { <32 x float> }
695+
%0 = fadd <vscale x 4 x float> %.coerce, %.coerce
696+
store <vscale x 4 x float> %0, ptr %retval
697+
%1 = load <32 x float>, ptr %retval
698+
%cast.scalable = tail call <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v32f32(<vscale x 4 x float> poison, <32 x float> %1, i64 0)
699+
ret <vscale x 4 x float> %cast.scalable
700+
}
701+
702+
declare <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v16f32(<vscale x 4 x float>, <16 x float>, i64 immarg)
703+
declare <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v32f32(<vscale x 4 x float>, <32 x float>, i64 immarg)
704+
705+
attributes #1 = { vscale_range(4,4) }

0 commit comments

Comments
 (0)