diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -2744,7 +2744,8 @@ } case TargetOpcode::G_SADDO: case TargetOpcode::G_UADDO: - case TargetOpcode::G_SSUBO: { + case TargetOpcode::G_SSUBO: + case TargetOpcode::G_USUBO: { // Emit the operation and get the correct condition code. MachineIRBuilder MIRBuilder(I); auto OpAndCC = emitOverflowOp(Opcode, I.getOperand(0).getReg(), @@ -4375,6 +4376,8 @@ return std::make_pair(emitADDS(Dst, LHS, RHS, MIRBuilder), AArch64CC::HS); case TargetOpcode::G_SSUBO: return std::make_pair(emitSUBS(Dst, LHS, RHS, MIRBuilder), AArch64CC::VS); + case TargetOpcode::G_USUBO: + return std::make_pair(emitSUBS(Dst, LHS, RHS, MIRBuilder), AArch64CC::HS); } } diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -165,7 +165,8 @@ getActionDefinitionsBuilder({G_SMULH, G_UMULH}).legalFor({s32, s64}); - getActionDefinitionsBuilder({G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO}) + getActionDefinitionsBuilder( + {G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO, G_USUBO}) .legalFor({{s32, s1}, {s64, s1}}) .minScalar(0, s32); diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir @@ -73,6 +73,44 @@ %5:_(s64) = G_ANYEXT %4(s8) $x0 = COPY %5(s64) +... +--- +name: test_scalar_uaddo_32 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_uaddo_32 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1 + ; CHECK: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[COPY]], [[COPY1]] + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO1]](s1) + ; CHECK: $w0 = COPY [[UADDO]](s32) + ; CHECK: $w1 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $w0 + %1:_(s32) = COPY $w1 + %2:_(s32), %3:_(s1) = G_UADDO %0, %1 + %4:_(s32) = G_ANYEXT %3 + $w0 = COPY %2(s32) + $w1 = COPY %4(s32) + +... +--- +name: test_scalar_saddo_32 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_saddo_32 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1 + ; CHECK: [[SADDO:%[0-9]+]]:_(s32), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO [[COPY]], [[COPY1]] + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[SADDO1]](s1) + ; CHECK: $w0 = COPY [[SADDO]](s32) + ; CHECK: $w1 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $w0 + %1:_(s32) = COPY $w1 + %2:_(s32), %3:_(s1) = G_SADDO %0, %1 + %4:_(s32) = G_ANYEXT %3 + $w0 = COPY %2(s32) + $w1 = COPY %4(s32) + ... --- name: test_vector_add diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sub.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sub.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sub.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sub.mir @@ -1,6 +1,59 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -march=aarch64 -run-pass=legalizer %s -o - | FileCheck %s --- +name: test_scalar_sub_big +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_sub_big + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2 + ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3 + ; CHECK: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[COPY]], [[COPY2]] + ; CHECK: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s1) = G_USUBE [[COPY1]], [[COPY3]], [[USUBO1]] + ; CHECK: $x0 = COPY [[USUBO]](s64) + ; CHECK: $x1 = COPY [[USUBE]](s64) + %0:_(s64) = COPY $x0 + %1:_(s64) = COPY $x1 + %2:_(s64) = COPY $x2 + %3:_(s64) = COPY $x3 + %4:_(s128) = G_MERGE_VALUES %0(s64), %1(s64) + %5:_(s128) = G_MERGE_VALUES %2(s64), %3(s64) + %6:_(s128) = G_SUB %4, %5 + %7:_(s64), %8:_(s64) = G_UNMERGE_VALUES %6(s128) + $x0 = COPY %7(s64) + $x1 = COPY %8(s64) + +... +--- +name: test_scalar_sub_big_nonpow2 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_sub_big_nonpow2 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2 + ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3 + ; CHECK: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[COPY]], [[COPY1]] + ; CHECK: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s1) = G_USUBE [[COPY1]], [[COPY2]], [[USUBO1]] + ; CHECK: [[USUBE2:%[0-9]+]]:_(s64), [[USUBE3:%[0-9]+]]:_(s1) = G_USUBE [[COPY2]], [[COPY3]], [[USUBE1]] + ; CHECK: $x0 = COPY [[USUBO]](s64) + ; CHECK: $x1 = COPY [[USUBE]](s64) + ; CHECK: $x2 = COPY [[USUBE2]](s64) + %0:_(s64) = COPY $x0 + %1:_(s64) = COPY $x1 + %2:_(s64) = COPY $x2 + %3:_(s64) = COPY $x3 + %4:_(s192) = G_MERGE_VALUES %0(s64), %1(s64), %2(s64) + %5:_(s192) = G_MERGE_VALUES %1(s64), %2(s64), %3(s64) + %6:_(s192) = G_SUB %4, %5 + %7:_(s64), %8:_(s64), %9:_(s64) = G_UNMERGE_VALUES %6(s192) + $x0 = COPY %7(s64) + $x1 = COPY %8(s64) + $x2 = COPY %9(s64) + +... +--- name: test_scalar_sub_small body: | bb.0.entry: @@ -21,3 +74,41 @@ $x0 = COPY %5(s64) ... +--- +name: test_scalar_usubo_32 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_usubo_32 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1 + ; CHECK: [[USUBO:%[0-9]+]]:_(s32), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[COPY]], [[COPY1]] + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[USUBO1]](s1) + ; CHECK: $w0 = COPY [[USUBO]](s32) + ; CHECK: $w1 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $w0 + %1:_(s32) = COPY $w1 + %2:_(s32), %3:_(s1) = G_USUBO %0, %1 + %4:_(s32) = G_ANYEXT %3 + $w0 = COPY %2(s32) + $w1 = COPY %4(s32) + +... +--- +name: test_scalar_ssubo_32 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_scalar_ssubo_32 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1 + ; CHECK: [[SSUBO:%[0-9]+]]:_(s32), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO [[COPY]], [[COPY1]] + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[SSUBO1]](s1) + ; CHECK: $w0 = COPY [[SSUBO]](s32) + ; CHECK: $w1 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $w0 + %1:_(s32) = COPY $w1 + %2:_(s32), %3:_(s1) = G_SSUBO %0, %1 + %4:_(s32) = G_ANYEXT %3 + $w0 = COPY %2(s32) + $w1 = COPY %4(s32) + +... diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -300,8 +300,9 @@ # DEBUG-NEXT: .. the first uncovered type index: 2, OK # DEBUG-NEXT: .. the first uncovered imm index: 0, OK # DEBUG-NEXT: G_USUBO (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_USUBE (opcode {{[0-9]+}}): 2 type indices, 0 imm indices # DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}} # DEBUG-NEXT: .. the first uncovered type index: 2, OK