Skip to content

Commit 61fff7a

Browse files
committed
[X86] Make sure we mark 128/256 MLOAD as Legal with VLX when min-legal-vector-width=256 is in effect.
This started triggering an assertion after r364718 when we made these Custom under AVX2. llvm-svn: 366382
1 parent 1375659 commit 61fff7a

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
12671267

12681268
for (auto VT : { MVT::v4i32, MVT::v8i32, MVT::v2i64, MVT::v4i64,
12691269
MVT::v4f32, MVT::v8f32, MVT::v2f64, MVT::v4f64 }) {
1270-
setOperationAction(ISD::MLOAD, VT, Custom);
1270+
setOperationAction(ISD::MLOAD, VT, Subtarget.hasVLX() ? Legal : Custom);
12711271
setOperationAction(ISD::MSTORE, VT, Legal);
12721272
}
12731273

@@ -1416,10 +1416,12 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
14161416
// With 512-bit vectors and no VLX, we prefer to widen MLOAD/MSTORE
14171417
// to 512-bit rather than use the AVX2 instructions so that we can use
14181418
// k-masks.
1419-
for (auto VT : {MVT::v4i32, MVT::v8i32, MVT::v2i64, MVT::v4i64,
1420-
MVT::v4f32, MVT::v8f32, MVT::v2f64, MVT::v4f64}) {
1421-
setOperationAction(ISD::MLOAD, VT, Subtarget.hasVLX() ? Legal : Custom);
1422-
setOperationAction(ISD::MSTORE, VT, Subtarget.hasVLX() ? Legal : Custom);
1419+
if (!Subtarget.hasVLX()) {
1420+
for (auto VT : {MVT::v4i32, MVT::v8i32, MVT::v2i64, MVT::v4i64,
1421+
MVT::v4f32, MVT::v8f32, MVT::v2f64, MVT::v4f64}) {
1422+
setOperationAction(ISD::MLOAD, VT, Custom);
1423+
setOperationAction(ISD::MSTORE, VT, Custom);
1424+
}
14231425
}
14241426

14251427
setOperationAction(ISD::TRUNCATE, MVT::v8i32, Custom);

llvm/test/CodeGen/X86/min-legal-vector-width.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,16 @@ define void @mul512(<64 x i8>* %a, <64 x i8>* %b, <64 x i8>* %c) "min-legal-vect
706706
store <64 x i8> %f, <64 x i8>* %c
707707
ret void
708708
}
709+
710+
; This threw an assertion at one point.
711+
define <4 x i32> @mload_v4i32(<4 x i32> %trigger, <4 x i32>* %addr, <4 x i32> %dst) "min-legal-vector-width"="256" {
712+
; CHECK-LABEL: mload_v4i32:
713+
; CHECK: # %bb.0:
714+
; CHECK-NEXT: vptestnmd %xmm0, %xmm0, %k1
715+
; CHECK-NEXT: vpblendmd (%rdi), %xmm1, %xmm0 {%k1}
716+
; CHECK-NEXT: retq
717+
%mask = icmp eq <4 x i32> %trigger, zeroinitializer
718+
%res = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(<4 x i32>* %addr, i32 4, <4 x i1> %mask, <4 x i32> %dst)
719+
ret <4 x i32> %res
720+
}
721+
declare <4 x i32> @llvm.masked.load.v4i32.p0v4i32(<4 x i32>*, i32, <4 x i1>, <4 x i32>)

0 commit comments

Comments
 (0)