Index: llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp =================================================================== --- llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -169,7 +169,7 @@ .scalarize(0); getActionDefinitionsBuilder({G_SREM, G_UREM, G_SDIVREM, G_UDIVREM}) - .lowerFor({s1, s8, s16, s32, s64, v2s64, v4s32, v2s32}) + .lowerFor({s8, s16, s32, s64, v2s64, v4s32, v2s32}) .widenScalarOrEltToNextPow2(0) .clampScalarOrElt(0, s32, s64) .clampNumElements(0, v2s32, v4s32) @@ -180,7 +180,7 @@ getActionDefinitionsBuilder({G_SMULO, G_UMULO}) .widenScalarToNextPow2(0, /*Min = */ 32) .clampScalar(0, s32, s64) - .lowerIf(typeIs(1, s1)); + .lower(); getActionDefinitionsBuilder({G_SMULH, G_UMULH}) .legalFor({s64, v8s16, v16s8, v4s32}) @@ -540,7 +540,7 @@ getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG_WITH_SUCCESS) .lowerIf( - all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(1, s1), typeIs(2, p0))); + all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(2, p0))); getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG) .customIf([](const LegalityQuery &Query) { Index: llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir =================================================================== --- llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir +++ llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir @@ -64,6 +64,57 @@ $w0 = COPY %5(s32) ... +--- +name: test_srem_1 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_srem_1 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC]], 1 + ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC1]], 1 + ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[SEXT_INREG]], [[SEXT_INREG1]] + ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[SEXT_INREG1]] + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[SEXT_INREG]], [[MUL]] + ; CHECK-NEXT: $w0 = COPY [[SUB]](s32) + %0:_(s64) = COPY $x0 + %1:_(s64) = COPY $x1 + %2:_(s1) = G_TRUNC %0(s64) + %3:_(s1) = G_TRUNC %1(s64) + %4:_(s1) = G_SREM %2, %3 + %5:_(s32) = G_ANYEXT %4(s1) + $w0 = COPY %5(s32) + +... + +--- +name: test_urem_1 +body: | + bb.0.entry: + ; CHECK-LABEL: name: test_urem_1 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]] + ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC1]], [[C]] + ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] + ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[UDIV]], [[AND1]] + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[AND]], [[MUL]] + ; CHECK-NEXT: $w0 = COPY [[SUB]](s32) + %0:_(s64) = COPY $x0 + %1:_(s64) = COPY $x1 + %2:_(s1) = G_TRUNC %0(s64) + %3:_(s1) = G_TRUNC %1(s64) + %4:_(s1) = G_UREM %2, %3 + %5:_(s32) = G_ANYEXT %4(s1) + $w0 = COPY %5(s32) + +... + --- name: test_frem body: |