[PATCH] D36899: [ARM] Avoid cases where isVZIPMask matches a mask where the first half is undef
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 14:27:02 PDT 2017
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.
As far as I've come with understanding the issue I'm looking into in PR33921, I think this is the place where the logic of the current code breaks.
Should the same be done in other functions like isVZIP_v_undef_Mask, isVUZP*Mask and isVTR*NMask as well?
This fixes PR33921.
https://reviews.llvm.org/D36899
Files:
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/vzip.ll
Index: test/CodeGen/ARM/vzip.ll
===================================================================
--- test/CodeGen/ARM/vzip.ll
+++ test/CodeGen/ARM/vzip.ll
@@ -270,8 +270,8 @@
; CHECK-LABEL: vzip_lower_shufflemask_undef:
; CHECK: @ BB#0: @ %entry
; CHECK-NEXT: vldr d17, [r1]
-; CHECK-NEXT: vldr d16, [r0]
-; CHECK-NEXT: vzip.16 d16, d17
+; CHECK-NEXT: vldr d18, [r0]
+; CHECK-NEXT: vzip.16 d18, d17
; CHECK-NEXT: vmov r0, r1, d16
; CHECK-NEXT: vmov r2, r3, d17
; CHECK-NEXT: mov pc, lr
@@ -282,6 +282,23 @@
ret <8 x i16> %0
}
+define <8 x i16> @vzip_lower_shufflemask_undef2(<4 x i16>* %A, <4 x i16>* %B) {
+; CHECK-LABEL: vzip_lower_shufflemask_undef2:
+; CHECK: @ BB#0: @ %entry
+; CHECK-NEXT: vldr d16, [r1]
+; CHECK-NEXT: vldr d19, [r0]
+; CHECK-NEXT: vtrn.16 d19, d16
+; CHECK-NEXT: vmov r0, r1, d18
+; CHECK-NEXT: vmov r2, r3, d19
+; CHECK-NEXT: mov pc, lr
+entry:
+ %tmp1 = load <4 x i16>, <4 x i16>* %A
+ %tmp2 = load <4 x i16>, <4 x i16>* %B
+ %cat = shufflevector <4 x i16> %tmp1, <4 x i16> %tmp2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %res = shufflevector <8 x i16> %cat, <8 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 4, i32 undef, i32 undef>
+ ret <8 x i16> %res
+}
+
define <4 x i32> @vzip_lower_shufflemask_zeroed(<2 x i32>* %A) {
; CHECK-LABEL: vzip_lower_shufflemask_zeroed:
; CHECK: @ BB#0: @ %entry
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -5982,8 +5982,15 @@
}
}
- if (M.size() == NumElts*2)
+ if (M.size() == NumElts*2) {
+ // If the first half of the target is undefined, the mask check above
+ // only checked the second half.
+ if (llvm::all_of(M.slice(0, NumElts), [&](int i) {
+ return i < 0;
+ }))
+ return false;
WhichResult = 0;
+ }
// VZIP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32.
if (VT.is64BitVector() && EltSz == 32)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36899.111743.patch
Type: text/x-patch
Size: 2124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170818/32ecf015/attachment.bin>
More information about the llvm-commits
mailing list