[llvm] r374377 - [ARM] VQSUB instruction
David Green via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 09:34:30 PDT 2019
Author: dmgreen
Date: Thu Oct 10 09:34:30 2019
New Revision: 374377
URL: http://llvm.org/viewvc/llvm-project?rev=374377&view=rev
Log:
[ARM] VQSUB instruction
Same as VQADD, VQSUB can be selected from llvm.ssub.sat intrinsics.
Differential Revision: https://reviews.llvm.org/D68567
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/ARM/ARMInstrMVE.td
llvm/trunk/test/CodeGen/Thumb2/mve-saturating-arith.ll
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=374377&r1=374376&r2=374377&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Oct 10 09:34:30 2019
@@ -267,6 +267,8 @@ void ARMTargetLowering::addMVEVectorType
setOperationAction(ISD::BSWAP, VT, Legal);
setOperationAction(ISD::SADDSAT, VT, Legal);
setOperationAction(ISD::UADDSAT, VT, Legal);
+ setOperationAction(ISD::SSUBSAT, VT, Legal);
+ setOperationAction(ISD::USUBSAT, VT, Legal);
// No native support for these.
setOperationAction(ISD::UDIV, VT, Expand);
Modified: llvm/trunk/lib/Target/ARM/ARMInstrMVE.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrMVE.td?rev=374377&r1=374376&r2=374377&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrMVE.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrMVE.td Thu Oct 10 09:34:30 2019
@@ -1567,6 +1567,14 @@ let Predicates = [HasMVEInt] in {
foreach VT = [instr.VT] in
def : Pat<(VT (saddsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
(VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
+ foreach instr = [MVE_VQSUBu8, MVE_VQSUBu16, MVE_VQSUBu32] in
+ foreach VT = [instr.VT] in
+ def : Pat<(VT (usubsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
+ (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
+ foreach instr = [MVE_VQSUBs8, MVE_VQSUBs16, MVE_VQSUBs32] in
+ foreach VT = [instr.VT] in
+ def : Pat<(VT (ssubsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
+ (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
}
Modified: llvm/trunk/test/CodeGen/Thumb2/mve-saturating-arith.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/mve-saturating-arith.ll?rev=374377&r1=374376&r2=374377&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Thumb2/mve-saturating-arith.ll (original)
+++ llvm/trunk/test/CodeGen/Thumb2/mve-saturating-arith.ll Thu Oct 10 09:34:30 2019
@@ -191,21 +191,7 @@ entry:
define arm_aapcs_vfpcc <16 x i8> @ssub_int8_t(<16 x i8> %src1, <16 x i8> %src2) {
; CHECK-LABEL: ssub_int8_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: .vsave {d8, d9}
-; CHECK-NEXT: vpush {d8, d9}
-; CHECK-NEXT: vsub.i8 q2, q0, q1
-; CHECK-NEXT: vmov.i8 q3, #0x80
-; CHECK-NEXT: vcmp.s8 lt, q2, zr
-; CHECK-NEXT: vmov.i8 q4, #0x7f
-; CHECK-NEXT: vpsel q3, q4, q3
-; CHECK-NEXT: vcmp.s8 gt, q0, q2
-; CHECK-NEXT: vmrs r0, p0
-; CHECK-NEXT: vcmp.s8 gt, q1, zr
-; CHECK-NEXT: vmrs r1, p0
-; CHECK-NEXT: eors r0, r1
-; CHECK-NEXT: vmsr p0, r0
-; CHECK-NEXT: vpsel q0, q3, q2
-; CHECK-NEXT: vpop {d8, d9}
+; CHECK-NEXT: vqsub.s8 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <16 x i8> @llvm.ssub.sat.v16i8(<16 x i8> %src1, <16 x i8> %src2)
@@ -215,21 +201,7 @@ entry:
define arm_aapcs_vfpcc <8 x i16> @ssub_int16_t(<8 x i16> %src1, <8 x i16> %src2) {
; CHECK-LABEL: ssub_int16_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: .vsave {d8, d9}
-; CHECK-NEXT: vpush {d8, d9}
-; CHECK-NEXT: vsub.i16 q2, q0, q1
-; CHECK-NEXT: vmov.i16 q3, #0x8000
-; CHECK-NEXT: vcmp.s16 lt, q2, zr
-; CHECK-NEXT: vmvn.i16 q4, #0x8000
-; CHECK-NEXT: vpsel q3, q4, q3
-; CHECK-NEXT: vcmp.s16 gt, q0, q2
-; CHECK-NEXT: vmrs r0, p0
-; CHECK-NEXT: vcmp.s16 gt, q1, zr
-; CHECK-NEXT: vmrs r1, p0
-; CHECK-NEXT: eors r0, r1
-; CHECK-NEXT: vmsr p0, r0
-; CHECK-NEXT: vpsel q0, q3, q2
-; CHECK-NEXT: vpop {d8, d9}
+; CHECK-NEXT: vqsub.s16 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <8 x i16> @llvm.ssub.sat.v8i16(<8 x i16> %src1, <8 x i16> %src2)
@@ -239,21 +211,7 @@ entry:
define arm_aapcs_vfpcc <4 x i32> @ssub_int32_t(<4 x i32> %src1, <4 x i32> %src2) {
; CHECK-LABEL: ssub_int32_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: .vsave {d8, d9}
-; CHECK-NEXT: vpush {d8, d9}
-; CHECK-NEXT: vsub.i32 q2, q0, q1
-; CHECK-NEXT: vmov.i32 q3, #0x80000000
-; CHECK-NEXT: vcmp.s32 lt, q2, zr
-; CHECK-NEXT: vmvn.i32 q4, #0x80000000
-; CHECK-NEXT: vpsel q3, q4, q3
-; CHECK-NEXT: vcmp.s32 gt, q0, q2
-; CHECK-NEXT: vmrs r0, p0
-; CHECK-NEXT: vcmp.s32 gt, q1, zr
-; CHECK-NEXT: vmrs r1, p0
-; CHECK-NEXT: eors r0, r1
-; CHECK-NEXT: vmsr p0, r0
-; CHECK-NEXT: vpsel q0, q3, q2
-; CHECK-NEXT: vpop {d8, d9}
+; CHECK-NEXT: vqsub.s32 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %src1, <4 x i32> %src2)
@@ -358,8 +316,7 @@ entry:
define arm_aapcs_vfpcc <16 x i8> @usub_int8_t(<16 x i8> %src1, <16 x i8> %src2) {
; CHECK-LABEL: usub_int8_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: vmax.u8 q0, q0, q1
-; CHECK-NEXT: vsub.i8 q0, q0, q1
+; CHECK-NEXT: vqsub.u8 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <16 x i8> @llvm.usub.sat.v16i8(<16 x i8> %src1, <16 x i8> %src2)
@@ -369,8 +326,7 @@ entry:
define arm_aapcs_vfpcc <8 x i16> @usub_int16_t(<8 x i16> %src1, <8 x i16> %src2) {
; CHECK-LABEL: usub_int16_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: vmax.u16 q0, q0, q1
-; CHECK-NEXT: vsub.i16 q0, q0, q1
+; CHECK-NEXT: vqsub.u16 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %src1, <8 x i16> %src2)
@@ -380,8 +336,7 @@ entry:
define arm_aapcs_vfpcc <4 x i32> @usub_int32_t(<4 x i32> %src1, <4 x i32> %src2) {
; CHECK-LABEL: usub_int32_t:
; CHECK: @ %bb.0: @ %entry
-; CHECK-NEXT: vmax.u32 q0, q0, q1
-; CHECK-NEXT: vsub.i32 q0, q0, q1
+; CHECK-NEXT: vqsub.u32 q0, q0, q1
; CHECK-NEXT: bx lr
entry:
%0 = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %src1, <4 x i32> %src2)
More information about the llvm-commits
mailing list