1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -verify-machineinstrs -mtriple aarch64-unknown-uknown -global-isel -run-pass=instruction-select %s -o - | FileCheck %s
10 tracksRegLiveness: true
13 liveins: $w0, $w1, $x2
15 ; CHECK-LABEL: name: saddo_s32
16 ; CHECK: liveins: $w0, $w1, $x2
17 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
18 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
19 ; CHECK: [[ADDSWrr:%[0-9]+]]:gpr32 = ADDSWrr [[COPY]], [[COPY1]], implicit-def $nzcv
20 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
21 ; CHECK: [[UBFMWri:%[0-9]+]]:gpr32 = UBFMWri [[CSINCWr]], 0, 0
22 ; CHECK: [[UBFMWri1:%[0-9]+]]:gpr32 = UBFMWri [[UBFMWri]], 0, 7
23 ; CHECK: $w0 = COPY [[UBFMWri1]]
24 ; CHECK: RET_ReallyLR implicit $w0
25 %0:gpr(s32) = COPY $w0
26 %1:gpr(s32) = COPY $w1
27 %3:gpr(s32), %4:gpr(s1) = G_SADDO %0, %1
28 %5:gpr(s8) = G_ZEXT %4(s1)
29 %6:gpr(s32) = G_ZEXT %5(s8)
31 RET_ReallyLR implicit $w0
39 tracksRegLiveness: true
42 liveins: $x0, $x1, $x2
44 ; CHECK-LABEL: name: saddo_s64
45 ; CHECK: liveins: $x0, $x1, $x2
46 ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
47 ; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1
48 ; CHECK: [[ADDSXrr:%[0-9]+]]:gpr64 = ADDSXrr [[COPY]], [[COPY1]], implicit-def $nzcv
49 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
50 ; CHECK: [[UBFMWri:%[0-9]+]]:gpr32 = UBFMWri [[CSINCWr]], 0, 0
51 ; CHECK: [[UBFMWri1:%[0-9]+]]:gpr32 = UBFMWri [[UBFMWri]], 0, 7
52 ; CHECK: $w0 = COPY [[UBFMWri1]]
53 ; CHECK: RET_ReallyLR implicit $w0
54 %0:gpr(s64) = COPY $x0
55 %1:gpr(s64) = COPY $x1
56 %3:gpr(s64), %4:gpr(s1) = G_SADDO %0, %1
57 %5:gpr(s8) = G_ZEXT %4(s1)
58 %6:gpr(s32) = G_ZEXT %5(s8)
60 RET_ReallyLR implicit $w0
68 tracksRegLiveness: true
71 liveins: $w0, $w1, $x2
72 ; Check that we get ADDSWri when we can fold in a constant.
74 ; CHECK-LABEL: name: saddo_s32_imm
75 ; CHECK: liveins: $w0, $w1, $x2
76 ; CHECK: %copy:gpr32sp = COPY $w0
77 ; CHECK: %add:gpr32 = ADDSWri %copy, 16, 0, implicit-def $nzcv
78 ; CHECK: %overflow:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
79 ; CHECK: $w0 = COPY %add
80 ; CHECK: RET_ReallyLR implicit $w0
81 %copy:gpr(s32) = COPY $w0
82 %constant:gpr(s32) = G_CONSTANT i32 16
83 %add:gpr(s32), %overflow:gpr(s1) = G_SADDO %copy, %constant
85 RET_ReallyLR implicit $w0
89 name: saddo_s32_shifted
93 tracksRegLiveness: true
96 liveins: $w0, $w1, $x2
97 ; Check that we get ADDSWrs when we can fold in a shift.
99 ; CHECK-LABEL: name: saddo_s32_shifted
100 ; CHECK: liveins: $w0, $w1, $x2
101 ; CHECK: %copy1:gpr32 = COPY $w0
102 ; CHECK: %copy2:gpr32 = COPY $w1
103 ; CHECK: %add:gpr32 = ADDSWrs %copy1, %copy2, 16, implicit-def $nzcv
104 ; CHECK: %overflow:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
105 ; CHECK: $w0 = COPY %add
106 ; CHECK: RET_ReallyLR implicit $w0
107 %copy1:gpr(s32) = COPY $w0
108 %copy2:gpr(s32) = COPY $w1
109 %constant:gpr(s32) = G_CONSTANT i32 16
110 %shift:gpr(s32) = G_SHL %copy2(s32), %constant(s32)
111 %add:gpr(s32), %overflow:gpr(s1) = G_SADDO %copy1, %shift
113 RET_ReallyLR implicit $w0
117 name: saddo_s32_neg_imm
120 regBankSelected: true
121 tracksRegLiveness: true
124 liveins: $w0, $w1, $x2
125 ; Check that we get SUBSWri when we can fold in a negative constant.
127 ; CHECK-LABEL: name: saddo_s32_neg_imm
128 ; CHECK: liveins: $w0, $w1, $x2
129 ; CHECK: %copy:gpr32sp = COPY $w0
130 ; CHECK: %add:gpr32 = SUBSWri %copy, 16, 0, implicit-def $nzcv
131 ; CHECK: %overflow:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
132 ; CHECK: $w0 = COPY %add
133 ; CHECK: RET_ReallyLR implicit $w0
134 %copy:gpr(s32) = COPY $w0
135 %constant:gpr(s32) = G_CONSTANT i32 -16
136 %add:gpr(s32), %overflow:gpr(s1) = G_SADDO %copy, %constant
138 RET_ReallyLR implicit $w0
142 name: saddo_arith_extended
145 regBankSelected: true
146 tracksRegLiveness: true
150 ; Check that we get ADDSXrx.
151 ; CHECK-LABEL: name: saddo_arith_extended
152 ; CHECK: liveins: $w0, $x0
153 ; CHECK: %reg0:gpr64sp = COPY $x0
154 ; CHECK: %reg1:gpr32 = COPY $w0
155 ; CHECK: %add:gpr64 = ADDSXrx %reg0, %reg1, 18, implicit-def $nzcv
156 ; CHECK: %flags:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
157 ; CHECK: $x0 = COPY %add
158 ; CHECK: RET_ReallyLR implicit $x0
159 %reg0:gpr(s64) = COPY $x0
160 %reg1:gpr(s32) = COPY $w0
161 %ext:gpr(s64) = G_ZEXT %reg1(s32)
162 %cst:gpr(s64) = G_CONSTANT i64 2
163 %shift:gpr(s64) = G_SHL %ext, %cst(s64)
164 %add:gpr(s64), %flags:gpr(s1) = G_SADDO %reg0, %shift
166 RET_ReallyLR implicit $x0