Skip to content

Commit 6693704

Browse files
committed
Add bail and test for type mismatch
1 parent a3a6f9f commit 6693704

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,8 @@ bool GVNPass::processMaskedLoad(IntrinsicInst *I) {
23012301
Value *Passthrough = I->getOperand(3);
23022302
Value *StoreVal;
23032303
if (!match(DepInst, m_MaskedStore(m_Value(StoreVal), m_Value(), m_Value(),
2304-
m_Specific(Mask))))
2304+
m_Specific(Mask))) ||
2305+
StoreVal->getType() != I->getType())
23052306
return false;
23062307

23072308
// Remove the load but generate a select for the passthrough

llvm/test/Transforms/GVN/masked-load-store.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ define <vscale x 4 x float> @forward_masked_load_scalable(ptr %0, ptr %1, <vscal
117117
ret <vscale x 4 x float> %load2
118118
}
119119

120+
define <vscale x 4 x float> @forward_masked_load_scalable_type_mismatch(ptr %0, ptr %1, <vscale x 4 x float> %passthrough) {
121+
; CHECK-LABEL: @forward_masked_load_scalable_type_mismatch(
122+
; CHECK-NEXT: [[MASK:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i32(i32 0, i32 4)
123+
; CHECK-NEXT: [[LOAD1:%.*]] = call <vscale x 4 x double> @llvm.masked.load.nxv4f64.p0(ptr [[TMP0:%.*]], i32 1, <vscale x 4 x i1> [[MASK]], <vscale x 4 x double> zeroinitializer)
124+
; CHECK-NEXT: call void @llvm.masked.store.nxv4f64.p0(<vscale x 4 x double> [[LOAD1]], ptr [[TMP1:%.*]], i32 1, <vscale x 4 x i1> [[MASK]])
125+
; CHECK-NEXT: [[LOAD2:%.*]] = call <vscale x 4 x float> @llvm.masked.load.nxv4f32.p0(ptr [[TMP1]], i32 1, <vscale x 4 x i1> [[MASK]], <vscale x 4 x float> [[PASSTHROUGH:%.*]])
126+
; CHECK-NEXT: ret <vscale x 4 x float> [[LOAD2]]
127+
;
128+
%mask = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i32(i32 0, i32 4)
129+
%load1 = call <vscale x 4 x double> @llvm.masked.load.nxv4f64.p0(ptr %0, i32 1, <vscale x 4 x i1> %mask, <vscale x 4 x double> zeroinitializer)
130+
call void @llvm.masked.store.nxv4f64.p0(<vscale x 4 x double> %load1, ptr %1, i32 1, <vscale x 4 x i1> %mask)
131+
%load2 = call <vscale x 4 x float> @llvm.masked.load.nxv4f32.p0(ptr %1, i32 1, <vscale x 4 x i1> %mask, <vscale x 4 x float> %passthrough)
132+
ret <vscale x 4 x float> %load2
133+
}
134+
120135
define <vscale x 4 x float> @generate_sel_with_passthrough(ptr %0, ptr %1, <vscale x 4 x float> %passthrough) {
121136
; CHECK-LABEL: @generate_sel_with_passthrough(
122137
; CHECK-NEXT: [[TMP3:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i32(i32 0, i32 4)

0 commit comments

Comments
 (0)