diff --git a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td index b65a63b5108dc..c0d480294dd8b 100644 --- a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td +++ b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td @@ -51,6 +51,9 @@ def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; +def : GINodeEquiv; +def : GINodeEquiv; +def : GINodeEquiv; def : GINodeEquiv; // G_INTTOPTR - SelectionDAG has no equivalent. // G_PTRTOINT - SelectionDAG has no equivalent. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index e0e1af78770de..efc62ea8ff6c2 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -797,6 +797,9 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) .clampMinNumElements(0, s16, 4) .alwaysLegal(); + getActionDefinitionsBuilder({G_TRUNC_SSAT_S, G_TRUNC_SSAT_U, G_TRUNC_USAT_U}) + .legalFor({{v8s8, v8s16}, {v4s16, v4s32}, {v2s32, v2s64}}); + getActionDefinitionsBuilder(G_SEXT_INREG) .legalFor({s32, s64}) .legalFor(PackedVectorAllTypeList) @@ -1644,6 +1647,11 @@ bool AArch64LegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper, MachineIRBuilder &MIB = Helper.MIRBuilder; MachineRegisterInfo &MRI = *MIB.getMRI(); + auto LowerUnaryOp = [&MI, &MIB](unsigned Opcode) { + MIB.buildInstr(Opcode, {MI.getOperand(0)}, {MI.getOperand(2)}); + MI.eraseFromParent(); + return true; + }; auto LowerBinOp = [&MI, &MIB](unsigned Opcode) { MIB.buildInstr(Opcode, {MI.getOperand(0)}, {MI.getOperand(2), MI.getOperand(3)}); @@ -1838,6 +1846,12 @@ bool AArch64LegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper, return LowerTriOp(AArch64::G_UDOT); case Intrinsic::aarch64_neon_sdot: return LowerTriOp(AArch64::G_SDOT); + case Intrinsic::aarch64_neon_sqxtn: + return LowerUnaryOp(AArch64::G_TRUNC_SSAT_S); + case Intrinsic::aarch64_neon_sqxtun: + return LowerUnaryOp(AArch64::G_TRUNC_SSAT_U); + case Intrinsic::aarch64_neon_uqxtn: + return LowerUnaryOp(AArch64::G_TRUNC_USAT_U); case Intrinsic::vector_reverse: // TODO: Add support for vector_reverse diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index 5c164bf672082..716665ee12c8d 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -321,14 +321,16 @@ # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: G_TRUNC_SSAT_S (opcode {{[0-9]+}}): 2 type indices, 0 imm indices -# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined -# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined +# DEBUG-NEXT: .. the first uncovered type index: 2, OK +# DEBUG-NEXT: .. the first uncovered imm index: 0, OK # DEBUG-NEXT: G_TRUNC_SSAT_U (opcode {{[0-9]+}}): 2 type indices, 0 imm indices -# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined -# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined +# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}} +# DEBUG-NEXT: .. the first uncovered type index: 2, OK +# DEBUG-NEXT: .. the first uncovered imm index: 0, OK # DEBUG-NEXT: G_TRUNC_USAT_U (opcode {{[0-9]+}}): 2 type indices, 0 imm indices -# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined -# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined +# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}} +# DEBUG-NEXT: .. the first uncovered type index: 2, OK +# DEBUG-NEXT: .. the first uncovered imm index: 0, OK # DEBUG-NEXT: G_CONSTANT (opcode {{[0-9]+}}): 1 type index, 0 imm indices # DEBUG-NEXT: .. the first uncovered type index: 1, OK # DEBUG-NEXT: .. the first uncovered imm index: 0, OK diff --git a/llvm/test/CodeGen/AArch64/arm64-vmovn.ll b/llvm/test/CodeGen/AArch64/arm64-vmovn.ll index 8e8642f90f133..3bfb40d888b97 100644 --- a/llvm/test/CodeGen/AArch64/arm64-vmovn.ll +++ b/llvm/test/CodeGen/AArch64/arm64-vmovn.ll @@ -1,114 +1,122 @@ -; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -global-isel=0 | FileCheck %s --check-prefixes=CHECK,CHECK-SD +; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -global-isel=1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI define <8 x i8> @xtn8b(<8 x i16> %A) nounwind { -;CHECK-LABEL: xtn8b: -;CHECK-NOT: ld1 -;CHECK: xtn.8b v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn8b: +; CHECK: // %bb.0: +; CHECK-NEXT: xtn.8b v0, v0 +; CHECK-NEXT: ret %tmp3 = trunc <8 x i16> %A to <8 x i8> ret <8 x i8> %tmp3 } define <4 x i16> @xtn4h(<4 x i32> %A) nounwind { -;CHECK-LABEL: xtn4h: -;CHECK-NOT: ld1 -;CHECK: xtn.4h v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn4h: +; CHECK: // %bb.0: +; CHECK-NEXT: xtn.4h v0, v0 +; CHECK-NEXT: ret %tmp3 = trunc <4 x i32> %A to <4 x i16> ret <4 x i16> %tmp3 } define <2 x i32> @xtn2s(<2 x i64> %A) nounwind { -;CHECK-LABEL: xtn2s: -;CHECK-NOT: ld1 -;CHECK: xtn.2s v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn2s: +; CHECK: // %bb.0: +; CHECK-NEXT: xtn.2s v0, v0 +; CHECK-NEXT: ret %tmp3 = trunc <2 x i64> %A to <2 x i32> ret <2 x i32> %tmp3 } define <16 x i8> @xtn2_16b(<8 x i8> %ret, <8 x i16> %A) nounwind { -;CHECK-LABEL: xtn2_16b: -;CHECK-NOT: ld1 -;CHECK: xtn2.16b v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn2_16b: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: xtn2.16b v0, v1 +; CHECK-NEXT: ret %tmp3 = trunc <8 x i16> %A to <8 x i8> %res = shufflevector <8 x i8> %ret, <8 x i8> %tmp3, <16 x i32> ret <16 x i8> %res } define <8 x i16> @xtn2_8h(<4 x i16> %ret, <4 x i32> %A) nounwind { -;CHECK-LABEL: xtn2_8h: -;CHECK-NOT: ld1 -;CHECK: xtn2.8h v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn2_8h: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: xtn2.8h v0, v1 +; CHECK-NEXT: ret %tmp3 = trunc <4 x i32> %A to <4 x i16> %res = shufflevector <4 x i16> %ret, <4 x i16> %tmp3, <8 x i32> ret <8 x i16> %res } define <4 x i32> @xtn2_4s(<2 x i32> %ret, <2 x i64> %A) nounwind { -;CHECK-LABEL: xtn2_4s: -;CHECK-NOT: ld1 -;CHECK: xtn2.4s v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: xtn2_4s: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: xtn2.4s v0, v1 +; CHECK-NEXT: ret %tmp3 = trunc <2 x i64> %A to <2 x i32> %res = shufflevector <2 x i32> %ret, <2 x i32> %tmp3, <4 x i32> ret <4 x i32> %res } define <8 x i8> @sqxtn8b(<8 x i16> %A) nounwind { -;CHECK-LABEL: sqxtn8b: -;CHECK-NOT: ld1 -;CHECK: sqxtn.8b v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn8b: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtn.8b v0, v0 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.sqxtn.v8i8(<8 x i16> %A) ret <8 x i8> %tmp3 } define <4 x i16> @sqxtn4h(<4 x i32> %A) nounwind { -;CHECK-LABEL: sqxtn4h: -;CHECK-NOT: ld1 -;CHECK: sqxtn.4h v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn4h: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtn.4h v0, v0 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.sqxtn.v4i16(<4 x i32> %A) ret <4 x i16> %tmp3 } define <2 x i32> @sqxtn2s(<2 x i64> %A) nounwind { -;CHECK-LABEL: sqxtn2s: -;CHECK-NOT: ld1 -;CHECK: sqxtn.2s v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn2s: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtn.2s v0, v0 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.sqxtn.v2i32(<2 x i64> %A) ret <2 x i32> %tmp3 } define <16 x i8> @sqxtn2_16b(<8 x i8> %ret, <8 x i16> %A) nounwind { -;CHECK-LABEL: sqxtn2_16b: -;CHECK-NOT: ld1 -;CHECK: sqxtn2.16b v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn2_16b: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtn2.16b v0, v1 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.sqxtn.v8i8(<8 x i16> %A) %res = shufflevector <8 x i8> %ret, <8 x i8> %tmp3, <16 x i32> ret <16 x i8> %res } define <8 x i16> @sqxtn2_8h(<4 x i16> %ret, <4 x i32> %A) nounwind { -;CHECK-LABEL: sqxtn2_8h: -;CHECK-NOT: ld1 -;CHECK: sqxtn2.8h v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn2_8h: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtn2.8h v0, v1 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.sqxtn.v4i16(<4 x i32> %A) %res = shufflevector <4 x i16> %ret, <4 x i16> %tmp3, <8 x i32> ret <8 x i16> %res } define <4 x i32> @sqxtn2_4s(<2 x i32> %ret, <2 x i64> %A) nounwind { -;CHECK-LABEL: sqxtn2_4s: -;CHECK-NOT: ld1 -;CHECK: sqxtn2.4s v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtn2_4s: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtn2.4s v0, v1 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.sqxtn.v2i32(<2 x i64> %A) %res = shufflevector <2 x i32> %ret, <2 x i32> %tmp3, <4 x i32> ret <4 x i32> %res @@ -119,57 +127,60 @@ declare <4 x i16> @llvm.aarch64.neon.sqxtn.v4i16(<4 x i32>) nounwind readnone declare <2 x i32> @llvm.aarch64.neon.sqxtn.v2i32(<2 x i64>) nounwind readnone define <8 x i8> @uqxtn8b(<8 x i16> %A) nounwind { -;CHECK-LABEL: uqxtn8b: -;CHECK-NOT: ld1 -;CHECK: uqxtn.8b v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn8b: +; CHECK: // %bb.0: +; CHECK-NEXT: uqxtn.8b v0, v0 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.uqxtn.v8i8(<8 x i16> %A) ret <8 x i8> %tmp3 } define <4 x i16> @uqxtn4h(<4 x i32> %A) nounwind { -;CHECK-LABEL: uqxtn4h: -;CHECK-NOT: ld1 -;CHECK: uqxtn.4h v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn4h: +; CHECK: // %bb.0: +; CHECK-NEXT: uqxtn.4h v0, v0 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.uqxtn.v4i16(<4 x i32> %A) ret <4 x i16> %tmp3 } define <2 x i32> @uqxtn2s(<2 x i64> %A) nounwind { -;CHECK-LABEL: uqxtn2s: -;CHECK-NOT: ld1 -;CHECK: uqxtn.2s v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn2s: +; CHECK: // %bb.0: +; CHECK-NEXT: uqxtn.2s v0, v0 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.uqxtn.v2i32(<2 x i64> %A) ret <2 x i32> %tmp3 } define <16 x i8> @uqxtn2_16b(<8 x i8> %ret, <8 x i16> %A) nounwind { -;CHECK-LABEL: uqxtn2_16b: -;CHECK-NOT: ld1 -;CHECK: uqxtn2.16b v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn2_16b: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: uqxtn2.16b v0, v1 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.uqxtn.v8i8(<8 x i16> %A) %res = shufflevector <8 x i8> %ret, <8 x i8> %tmp3, <16 x i32> ret <16 x i8> %res } define <8 x i16> @uqxtn2_8h(<4 x i16> %ret, <4 x i32> %A) nounwind { -;CHECK-LABEL: uqxtn2_8h: -;CHECK-NOT: ld1 -;CHECK: uqxtn2.8h v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn2_8h: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: uqxtn2.8h v0, v1 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.uqxtn.v4i16(<4 x i32> %A) %res = shufflevector <4 x i16> %ret, <4 x i16> %tmp3, <8 x i32> ret <8 x i16> %res } define <4 x i32> @uqxtn2_4s(<2 x i32> %ret, <2 x i64> %A) nounwind { -;CHECK-LABEL: uqxtn2_4s: -;CHECK-NOT: ld1 -;CHECK: uqxtn2.4s v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: uqxtn2_4s: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: uqxtn2.4s v0, v1 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.uqxtn.v2i32(<2 x i64> %A) %res = shufflevector <2 x i32> %ret, <2 x i32> %tmp3, <4 x i32> ret <4 x i32> %res @@ -180,57 +191,60 @@ declare <4 x i16> @llvm.aarch64.neon.uqxtn.v4i16(<4 x i32>) nounwind readnone declare <2 x i32> @llvm.aarch64.neon.uqxtn.v2i32(<2 x i64>) nounwind readnone define <8 x i8> @sqxtun8b(<8 x i16> %A) nounwind { -;CHECK-LABEL: sqxtun8b: -;CHECK-NOT: ld1 -;CHECK: sqxtun.8b v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun8b: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtun.8b v0, v0 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.sqxtun.v8i8(<8 x i16> %A) ret <8 x i8> %tmp3 } define <4 x i16> @sqxtun4h(<4 x i32> %A) nounwind { -;CHECK-LABEL: sqxtun4h: -;CHECK-NOT: ld1 -;CHECK: sqxtun.4h v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun4h: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtun.4h v0, v0 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.sqxtun.v4i16(<4 x i32> %A) ret <4 x i16> %tmp3 } define <2 x i32> @sqxtun2s(<2 x i64> %A) nounwind { -;CHECK-LABEL: sqxtun2s: -;CHECK-NOT: ld1 -;CHECK: sqxtun.2s v0, v0 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun2s: +; CHECK: // %bb.0: +; CHECK-NEXT: sqxtun.2s v0, v0 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.sqxtun.v2i32(<2 x i64> %A) ret <2 x i32> %tmp3 } define <16 x i8> @sqxtun2_16b(<8 x i8> %ret, <8 x i16> %A) nounwind { -;CHECK-LABEL: sqxtun2_16b: -;CHECK-NOT: ld1 -;CHECK: sqxtun2.16b v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun2_16b: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtun2.16b v0, v1 +; CHECK-NEXT: ret %tmp3 = call <8 x i8> @llvm.aarch64.neon.sqxtun.v8i8(<8 x i16> %A) %res = shufflevector <8 x i8> %ret, <8 x i8> %tmp3, <16 x i32> ret <16 x i8> %res } define <8 x i16> @sqxtun2_8h(<4 x i16> %ret, <4 x i32> %A) nounwind { -;CHECK-LABEL: sqxtun2_8h: -;CHECK-NOT: ld1 -;CHECK: sqxtun2.8h v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun2_8h: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtun2.8h v0, v1 +; CHECK-NEXT: ret %tmp3 = call <4 x i16> @llvm.aarch64.neon.sqxtun.v4i16(<4 x i32> %A) %res = shufflevector <4 x i16> %ret, <4 x i16> %tmp3, <8 x i32> ret <8 x i16> %res } define <4 x i32> @sqxtun2_4s(<2 x i32> %ret, <2 x i64> %A) nounwind { -;CHECK-LABEL: sqxtun2_4s: -;CHECK-NOT: ld1 -;CHECK: sqxtun2.4s v0, v1 -;CHECK-NEXT: ret +; CHECK-LABEL: sqxtun2_4s: +; CHECK: // %bb.0: +; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 +; CHECK-NEXT: sqxtun2.4s v0, v1 +; CHECK-NEXT: ret %tmp3 = call <2 x i32> @llvm.aarch64.neon.sqxtun.v2i32(<2 x i64> %A) %res = shufflevector <2 x i32> %ret, <2 x i32> %tmp3, <4 x i32> ret <4 x i32> %res @@ -240,3 +254,6 @@ declare <8 x i8> @llvm.aarch64.neon.sqxtun.v8i8(<8 x i16>) nounwind readnone declare <4 x i16> @llvm.aarch64.neon.sqxtun.v4i16(<4 x i32>) nounwind readnone declare <2 x i32> @llvm.aarch64.neon.sqxtun.v2i32(<2 x i64>) nounwind readnone +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: +; CHECK-GI: {{.*}} +; CHECK-SD: {{.*}}