Index: llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp =================================================================== --- llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -771,6 +771,12 @@ {v4s16, v4s16}, {v8s16, v8s16}}); + // TODO: Vector types. + getActionDefinitionsBuilder({G_SADDSAT, G_SSUBSAT}) + .widenScalarToNextPow2(0, /*Min = */ 32) + .clampScalar(0, s32, s64) + .lowerIf(typeInSet(0, {s32, s64})); + getLegacyLegalizerInfo().computeTables(); verify(*ST.getInstrInfo()); } Index: llvm/test/CodeGen/AArch64/GlobalISel/legalize-saddsat.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/GlobalISel/legalize-saddsat.mir @@ -0,0 +1,248 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=aarch64 -run-pass=legalizer -verify-machineinstrs -global-isel-abort=0 %s -o - | FileCheck %s + +... +--- +name: s32 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1 + ; CHECK-LABEL: name: s32 + ; CHECK: liveins: $w0, $w1 + ; CHECK: %x:_(s32) = COPY $w0 + ; CHECK: %y:_(s32) = COPY $w1 + ; CHECK: [[SADDO:%[0-9]+]]:_(s32), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO %x, %y + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SADDO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C1]] + ; CHECK: %saddsat:_(s32) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: $w0 = COPY %saddsat(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %x:_(s32) = COPY $w0 + %y:_(s32) = COPY $w1 + %saddsat:_(s32) = G_SADDSAT %x, %y + $w0 = COPY %saddsat(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s64 +tracksRegLiveness: true +body: | + bb.0: + liveins: $x0, $x1 + ; CHECK-LABEL: name: s64 + ; CHECK: liveins: $x0, $x1 + ; CHECK: %x:_(s64) = COPY $x0 + ; CHECK: %y:_(s64) = COPY $x1 + ; CHECK: [[SADDO:%[0-9]+]]:_(s64), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO %x, %y + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SADDO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -9223372036854775808 + ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[ASHR]], [[C1]] + ; CHECK: %saddsat:_(s64) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: $x0 = COPY %saddsat(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %x:_(s64) = COPY $x0 + %y:_(s64) = COPY $x1 + %saddsat:_(s64) = G_SADDSAT %x, %y + $x0 = COPY %saddsat(s64) + RET_ReallyLR implicit $x0 + +... +--- +name: s16 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s16 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SADDO:%[0-9]+]]:_(s32), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SADDO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s16) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s16) = G_TRUNC %copy_2(s32) + %saddsat:_(s16) = G_SADDSAT %x, %y + %ext:_(s32) = G_ANYEXT %saddsat(s16) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s1 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s1 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SADDO:%[0-9]+]]:_(s32), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO [[SHL]], [[SHL1]] + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SADDO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C1]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s1) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s1) = G_TRUNC %copy_2(s32) + %saddsat:_(s1) = G_SADDSAT %x, %y + %ext:_(s32) = G_ANYEXT %saddsat(s1) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s3 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s3 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SADDO:%[0-9]+]]:_(s32), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SADDO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s3) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s3) = G_TRUNC %copy_2(s32) + %saddsat:_(s3) = G_SADDSAT %x, %y + %ext:_(s32) = G_ANYEXT %saddsat(s3) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s36 +tracksRegLiveness: true +body: | + bb.0: + liveins: $x0, $x1 + + ; CHECK-LABEL: name: s36 + ; CHECK: liveins: $x0, $x1 + ; CHECK: %copy_1:_(s64) = COPY $x0 + ; CHECK: %copy_2:_(s64) = COPY $x1 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY %copy_1(s64) + ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %copy_2(s64) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28 + ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SADDO:%[0-9]+]]:_(s64), [[SADDO1:%[0-9]+]]:_(s1) = G_SADDO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SADDO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -9223372036854775808 + ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[SADDO1]](s1), [[ADD]], [[SADDO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s64) = COPY [[ASHR1]](s64) + ; CHECK: $x0 = COPY %ext(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %copy_1:_(s64) = COPY $x0 + %x:_(s36) = G_TRUNC %copy_1(s64) + %copy_2:_(s64) = COPY $x1 + %y:_(s36) = G_TRUNC %copy_2(s64) + %saddsat:_(s36) = G_SADDSAT %x, %y + %ext:_(s64) = G_ANYEXT %saddsat(s36) + $x0 = COPY %ext(s64) + RET_ReallyLR implicit $x0 + +... +--- +name: s88 +tracksRegLiveness: true +body: | + bb.0: + liveins: $q0, $q1, $x0 + ; CHECK-LABEL: name: s88 + ; CHECK: liveins: $q0, $q1, $x0 + ; CHECK: %copy_1:_(s128) = COPY $q0 + ; CHECK: %x:_(s88) = G_TRUNC %copy_1(s128) + ; CHECK: %copy_2:_(s128) = COPY $q1 + ; CHECK: %y:_(s88) = G_TRUNC %copy_2(s128) + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT %x(s88) + ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s128) = G_ANYEXT %y(s88) + ; CHECK: [[C:%[0-9]+]]:_(s128) = G_CONSTANT i128 40 + ; CHECK: [[SHL:%[0-9]+]]:_(s128) = G_SHL [[ANYEXT]], [[C]](s128) + ; CHECK: [[SHL1:%[0-9]+]]:_(s128) = G_SHL [[ANYEXT1]], [[C]](s128) + ; CHECK: [[SADDSAT:%[0-9]+]]:_(s128) = G_SADDSAT [[SHL]], [[SHL1]] + ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[C]](s128) + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 64 + ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[SADDSAT]](s128) + ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[TRUNC]], [[C1]] + ; CHECK: [[SUB1:%[0-9]+]]:_(s64) = G_SUB [[C1]], [[TRUNC]] + ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 + ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[TRUNC]](s64), [[C1]] + ; CHECK: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32) + ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[TRUNC]](s64), [[C2]] + ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32) + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[TRUNC]](s64) + ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[TRUNC]](s64) + ; CHECK: [[SHL2:%[0-9]+]]:_(s64) = G_SHL [[UV1]], [[SUB1]](s64) + ; CHECK: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL2]] + ; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[C3]](s64) + ; CHECK: [[ASHR2:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[SUB]](s64) + ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[OR]], [[ASHR2]] + ; CHECK: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC2]](s1), [[UV]], [[SELECT]] + ; CHECK: [[SELECT2:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[ASHR]], [[ASHR1]] + ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[SELECT1]](s64), [[SELECT2]](s64) + ; CHECK: %saddsat:_(s88) = G_TRUNC [[MV]](s128) + ; CHECK: %trunc:_(s64) = G_TRUNC %saddsat(s88) + ; CHECK: $x0 = COPY %trunc(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %copy_1:_(s128) = COPY $q0 + %x:_(s88) = G_TRUNC %copy_1(s128) + %copy_2:_(s128) = COPY $q1 + %y:_(s88) = G_TRUNC %copy_2(s128) + %saddsat:_(s88) = G_SADDSAT %x, %y + %trunc:_(s64) = G_TRUNC %saddsat(s88) + $x0 = COPY %trunc(s64) + RET_ReallyLR implicit $x0 Index: llvm/test/CodeGen/AArch64/GlobalISel/legalize-ssubsat.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/GlobalISel/legalize-ssubsat.mir @@ -0,0 +1,248 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=aarch64 -run-pass=legalizer -verify-machineinstrs -global-isel-abort=0 %s -o - | FileCheck %s + +... +--- +name: s32 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1 + ; CHECK-LABEL: name: s32 + ; CHECK: liveins: $w0, $w1 + ; CHECK: %x:_(s32) = COPY $w0 + ; CHECK: %y:_(s32) = COPY $w1 + ; CHECK: [[SSUBO:%[0-9]+]]:_(s32), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO %x, %y + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SSUBO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C1]] + ; CHECK: %ssubsat:_(s32) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: $w0 = COPY %ssubsat(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %x:_(s32) = COPY $w0 + %y:_(s32) = COPY $w1 + %ssubsat:_(s32) = G_SSUBSAT %x, %y + $w0 = COPY %ssubsat(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s64 +tracksRegLiveness: true +body: | + bb.0: + liveins: $x0, $x1 + ; CHECK-LABEL: name: s64 + ; CHECK: liveins: $x0, $x1 + ; CHECK: %x:_(s64) = COPY $x0 + ; CHECK: %y:_(s64) = COPY $x1 + ; CHECK: [[SSUBO:%[0-9]+]]:_(s64), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO %x, %y + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SSUBO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -9223372036854775808 + ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[ASHR]], [[C1]] + ; CHECK: %ssubsat:_(s64) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: $x0 = COPY %ssubsat(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %x:_(s64) = COPY $x0 + %y:_(s64) = COPY $x1 + %ssubsat:_(s64) = G_SSUBSAT %x, %y + $x0 = COPY %ssubsat(s64) + RET_ReallyLR implicit $x0 + +... +--- +name: s16 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s16 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SSUBO:%[0-9]+]]:_(s32), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SSUBO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s16) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s16) = G_TRUNC %copy_2(s32) + %ssubsat:_(s16) = G_SSUBSAT %x, %y + %ext:_(s32) = G_ANYEXT %ssubsat(s16) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s1 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s1 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SSUBO:%[0-9]+]]:_(s32), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO [[SHL]], [[SHL1]] + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SSUBO]], [[C]](s64) + ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C1]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s1) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s1) = G_TRUNC %copy_2(s32) + %ssubsat:_(s1) = G_SSUBSAT %x, %y + %ext:_(s32) = G_ANYEXT %ssubsat(s1) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s3 +tracksRegLiveness: true +body: | + bb.0: + liveins: $w0, $w1, $w2 + + ; CHECK-LABEL: name: s3 + ; CHECK: liveins: $w0, $w1, $w2 + ; CHECK: %copy_1:_(s32) = COPY $w0 + ; CHECK: %copy_2:_(s32) = COPY $w1 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY %copy_1(s32) + ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %copy_2(s32) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 29 + ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SSUBO:%[0-9]+]]:_(s32), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31 + ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SSUBO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483648 + ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s32) = COPY [[ASHR1]](s32) + ; CHECK: $w0 = COPY %ext(s32) + ; CHECK: RET_ReallyLR implicit $w0 + %copy_1:_(s32) = COPY $w0 + %x:_(s3) = G_TRUNC %copy_1(s32) + %copy_2:_(s32) = COPY $w1 + %y:_(s3) = G_TRUNC %copy_2(s32) + %ssubsat:_(s3) = G_SSUBSAT %x, %y + %ext:_(s32) = G_ANYEXT %ssubsat(s3) + $w0 = COPY %ext(s32) + RET_ReallyLR implicit $w0 + +... +--- +name: s36 +tracksRegLiveness: true +body: | + bb.0: + liveins: $x0, $x1 + + ; CHECK-LABEL: name: s36 + ; CHECK: liveins: $x0, $x1 + ; CHECK: %copy_1:_(s64) = COPY $x0 + ; CHECK: %copy_2:_(s64) = COPY $x1 + ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY %copy_1(s64) + ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %copy_2(s64) + ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28 + ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64) + ; CHECK: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C]](s64) + ; CHECK: [[SSUBO:%[0-9]+]]:_(s64), [[SSUBO1:%[0-9]+]]:_(s1) = G_SSUBO [[SHL]], [[SHL1]] + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SSUBO]], [[C1]](s64) + ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -9223372036854775808 + ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[ASHR]], [[C2]] + ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[SSUBO1]](s1), [[ADD]], [[SSUBO]] + ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SELECT]], [[C]](s64) + ; CHECK: %ext:_(s64) = COPY [[ASHR1]](s64) + ; CHECK: $x0 = COPY %ext(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %copy_1:_(s64) = COPY $x0 + %x:_(s36) = G_TRUNC %copy_1(s64) + %copy_2:_(s64) = COPY $x1 + %y:_(s36) = G_TRUNC %copy_2(s64) + %ssubsat:_(s36) = G_SSUBSAT %x, %y + %ext:_(s64) = G_ANYEXT %ssubsat(s36) + $x0 = COPY %ext(s64) + RET_ReallyLR implicit $x0 + +... +--- +name: s88 +tracksRegLiveness: true +body: | + bb.0: + liveins: $q0, $q1, $x0 + ; CHECK-LABEL: name: s88 + ; CHECK: liveins: $q0, $q1, $x0 + ; CHECK: %copy_1:_(s128) = COPY $q0 + ; CHECK: %x:_(s88) = G_TRUNC %copy_1(s128) + ; CHECK: %copy_2:_(s128) = COPY $q1 + ; CHECK: %y:_(s88) = G_TRUNC %copy_2(s128) + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT %x(s88) + ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s128) = G_ANYEXT %y(s88) + ; CHECK: [[C:%[0-9]+]]:_(s128) = G_CONSTANT i128 40 + ; CHECK: [[SHL:%[0-9]+]]:_(s128) = G_SHL [[ANYEXT]], [[C]](s128) + ; CHECK: [[SHL1:%[0-9]+]]:_(s128) = G_SHL [[ANYEXT1]], [[C]](s128) + ; CHECK: [[SSUBSAT:%[0-9]+]]:_(s128) = G_SSUBSAT [[SHL]], [[SHL1]] + ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[C]](s128) + ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 64 + ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[SSUBSAT]](s128) + ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[TRUNC]], [[C1]] + ; CHECK: [[SUB1:%[0-9]+]]:_(s64) = G_SUB [[C1]], [[TRUNC]] + ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 + ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[TRUNC]](s64), [[C1]] + ; CHECK: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32) + ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[TRUNC]](s64), [[C2]] + ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32) + ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[TRUNC]](s64) + ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[TRUNC]](s64) + ; CHECK: [[SHL2:%[0-9]+]]:_(s64) = G_SHL [[UV1]], [[SUB1]](s64) + ; CHECK: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL2]] + ; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[C3]](s64) + ; CHECK: [[ASHR2:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[SUB]](s64) + ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[OR]], [[ASHR2]] + ; CHECK: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC2]](s1), [[UV]], [[SELECT]] + ; CHECK: [[SELECT2:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[ASHR]], [[ASHR1]] + ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[SELECT1]](s64), [[SELECT2]](s64) + ; CHECK: %ssubsat:_(s88) = G_TRUNC [[MV]](s128) + ; CHECK: %trunc:_(s64) = G_TRUNC %ssubsat(s88) + ; CHECK: $x0 = COPY %trunc(s64) + ; CHECK: RET_ReallyLR implicit $x0 + %copy_1:_(s128) = COPY $q0 + %x:_(s88) = G_TRUNC %copy_1(s128) + %copy_2:_(s128) = COPY $q1 + %y:_(s88) = G_TRUNC %copy_2(s128) + %ssubsat:_(s88) = G_SSUBSAT %x, %y + %trunc:_(s64) = G_TRUNC %ssubsat(s88) + $x0 = COPY %trunc(s64) + RET_ReallyLR implicit $x0