1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -global-isel -verify-machineinstrs %s -o - | FileCheck %s
7 tracksRegLiveness: true
10 ; CHECK-LABEL: name: test
11 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
12 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -2147483647
13 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 31
14 ; CHECK-NEXT: [[UMULH:%[0-9]+]]:_(s32) = G_UMULH [[C]], [[C1]]
15 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[UMULH]], [[C2]](s32)
16 ; CHECK-NEXT: [[UREM:%[0-9]+]]:_(s32) = G_UREM [[C]], [[C]]
17 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[UREM]](s32)
18 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[LSHR]](s32)
19 ; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[TRUNC]](s8)
20 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[ZEXT]], [[SEXT]]
21 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[OR]](s64)
22 ; CHECK-NEXT: $w0 = COPY [[TRUNC1]](s32)
23 ; CHECK-NEXT: RET_ReallyLR implicit $w0
24 %0:_(s16) = G_CONSTANT i16 0
25 %2:_(s1) = G_CONSTANT i1 true
26 %1:_(s1) = G_ICMP intpred(sge), %0(s16), %0
27 %3:_(s8) = G_SEXT %2(s1)
28 %4:_(s32) = G_SEXT %3(s8)
29 %5:_(s32) = G_SEXT %1(s1)
30 %6:_(s32) = G_UDIV %4, %5
31 %7:_(s32) = COPY %5(s32)
32 %8:_(s32) = G_SEXT %2(s1)
33 %9:_(s32) = G_UREM %7, %8
34 %10:_(s8) = G_TRUNC %9(s32)
35 %11:_(s64) = G_ZEXT %6(s32)
36 %12:_(s64) = G_SEXT %10(s8)
37 %13:_(s64) = G_OR %11, %12
38 %14:_(s32) = G_TRUNC %13(s64)
40 RET_ReallyLR implicit $w0
44 # Check with the div and rem the other way around
46 name: test_inverted_div_rem
48 tracksRegLiveness: true
51 ; CHECK-LABEL: name: test_inverted_div_rem
52 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
53 ; CHECK-NEXT: [[UDIVREM:%[0-9]+]]:_(s32), [[UDIVREM1:%[0-9]+]]:_ = G_UDIVREM [[C]], [[C]]
54 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[UDIVREM]](s32)
55 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[UDIVREM1]](s32)
56 ; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[TRUNC]](s8)
57 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[ZEXT]], [[SEXT]]
58 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[OR]](s64)
59 ; CHECK-NEXT: $w0 = COPY [[TRUNC1]](s32)
60 ; CHECK-NEXT: RET_ReallyLR implicit $w0
61 %0:_(s16) = G_CONSTANT i16 0
62 %2:_(s1) = G_CONSTANT i1 true
63 %1:_(s1) = G_ICMP intpred(sge), %0(s16), %0
64 %3:_(s8) = G_SEXT %2(s1)
65 %4:_(s32) = G_SEXT %3(s8)
66 %5:_(s32) = G_SEXT %1(s1)
67 %6:_(s32) = G_UREM %4, %5
68 %7:_(s32) = COPY %5(s32)
69 %8:_(s32) = G_SEXT %2(s1)
70 %9:_(s32) = G_UDIV %7, %8
71 %10:_(s8) = G_TRUNC %9(s32)
72 %11:_(s64) = G_ZEXT %6(s32)
73 %12:_(s64) = G_SEXT %10(s8)
74 %13:_(s64) = G_OR %11, %12
75 %14:_(s32) = G_TRUNC %13(s64)
77 RET_ReallyLR implicit $w0