Skip to content

Commit 2cd59bd

Browse files
committed
[RISCV] Add test case for miscompile in gather -> strided load combine. NFC
This shows the issue in llvm#82430, but triggers it via the widening SEW combine rather than a GEP that RISCVGatherScatterLowering doesn't detect.
1 parent 3f732c4 commit 2cd59bd

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Diff for: llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll

+47
Original file line numberDiff line numberDiff line change
@@ -15086,5 +15086,52 @@ define <32 x i64> @mgather_strided_split(ptr %base) {
1508615086
ret <32 x i64> %x
1508715087
}
1508815088

15089+
; FIXME: This is a miscompile triggered by the mgather ->
15090+
; riscv.masked.strided.load combine. In order for it to trigger we need either a
15091+
; strided gather that RISCVGatherScatterLowering doesn't pick up, or a new
15092+
; strided gather generated by the widening sew combine.
15093+
define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) {
15094+
; RV32V-LABEL: masked_gather_widen_sew_negative_stride:
15095+
; RV32V: # %bb.0:
15096+
; RV32V-NEXT: addi a0, a0, -128
15097+
; RV32V-NEXT: li a1, -128
15098+
; RV32V-NEXT: vsetivli zero, 2, e64, m1, ta, ma
15099+
; RV32V-NEXT: vlse64.v v8, (a0), a1
15100+
; RV32V-NEXT: ret
15101+
;
15102+
; RV64V-LABEL: masked_gather_widen_sew_negative_stride:
15103+
; RV64V: # %bb.0:
15104+
; RV64V-NEXT: addi a0, a0, -128
15105+
; RV64V-NEXT: li a1, -128
15106+
; RV64V-NEXT: vsetivli zero, 2, e64, m1, ta, ma
15107+
; RV64V-NEXT: vlse64.v v8, (a0), a1
15108+
; RV64V-NEXT: ret
15109+
;
15110+
; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
15111+
; RV32ZVE32F: # %bb.0:
15112+
; RV32ZVE32F-NEXT: lui a1, 16392
15113+
; RV32ZVE32F-NEXT: addi a1, a1, 1152
15114+
; RV32ZVE32F-NEXT: vsetivli zero, 4, e32, m1, ta, ma
15115+
; RV32ZVE32F-NEXT: vmv.s.x v9, a1
15116+
; RV32ZVE32F-NEXT: vluxei8.v v8, (a0), v9
15117+
; RV32ZVE32F-NEXT: ret
15118+
;
15119+
; RV64ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
15120+
; RV64ZVE32F: # %bb.0:
15121+
; RV64ZVE32F-NEXT: addi a1, a0, 128
15122+
; RV64ZVE32F-NEXT: lw a2, 132(a0)
15123+
; RV64ZVE32F-NEXT: lw a3, 0(a0)
15124+
; RV64ZVE32F-NEXT: lw a0, 4(a0)
15125+
; RV64ZVE32F-NEXT: vsetivli zero, 4, e32, m1, ta, ma
15126+
; RV64ZVE32F-NEXT: vlse32.v v8, (a1), zero
15127+
; RV64ZVE32F-NEXT: vslide1down.vx v8, v8, a2
15128+
; RV64ZVE32F-NEXT: vslide1down.vx v8, v8, a3
15129+
; RV64ZVE32F-NEXT: vslide1down.vx v8, v8, a0
15130+
; RV64ZVE32F-NEXT: ret
15131+
%ptrs = getelementptr i32, ptr %base, <4 x i64> <i64 32, i64 33, i64 0, i64 1>
15132+
%x = call <4 x i32> @llvm.masked.gather.v4i32.v32p0(<4 x ptr> %ptrs, i32 8, <4 x i1> shufflevector(<4 x i1> insertelement(<4 x i1> poison, i1 true, i32 0), <4 x i1> poison, <4 x i32> zeroinitializer), <4 x i32> poison)
15133+
ret <4 x i32> %x
15134+
}
15135+
1508915136
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
1509015137
; RV64: {{.*}}

0 commit comments

Comments
 (0)