| OLD | NEW |
| 1 ; Assembly test for simple arithmetic operations. | 1 ; Assembly test for simple arithmetic operations. |
| 2 | 2 |
| 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 4 ; RUN: --target x8632 -i %s --args -O2 \ | 4 ; RUN: --target x8632 -i %s --args -O2 \ |
| 5 ; RUN: | %if --need=target_X8632 --command FileCheck %s | 5 ; RUN: | %if --need=target_X8632 --command FileCheck %s |
| 6 | 6 |
| 7 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) | 7 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) |
| 8 ; once enough infrastructure is in. Also, switch to --filetype=obj | 8 ; once enough infrastructure is in. Also, switch to --filetype=obj |
| 9 ; when possible. | 9 ; when possible. |
| 10 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 10 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 11 ; RUN: --command %p2i --filetype=asm --assemble \ | 11 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \ |
| 12 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ | 12 ; RUN: -i %s --args -O2 --skip-unimplemented \ |
| 13 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 13 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 14 ; RUN: --command FileCheck --check-prefix ARM32 %s | 14 ; RUN: --command FileCheck --check-prefix ARM32 %s |
| 15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 16 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \ |
| 17 ; RUN: -i %s --args -O2 --mattr=hwdiv-arm --skip-unimplemented \ |
| 18 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 19 ; RUN: --command FileCheck --check-prefix ARM32HWDIV %s |
| 15 | 20 |
| 16 define i32 @Add(i32 %a, i32 %b) { | 21 define i32 @Add(i32 %a, i32 %b) { |
| 17 entry: | 22 entry: |
| 18 %add = add i32 %b, %a | 23 %add = add i32 %b, %a |
| 19 ret i32 %add | 24 ret i32 %add |
| 20 } | 25 } |
| 21 ; CHECK-LABEL: Add | 26 ; CHECK-LABEL: Add |
| 22 ; CHECK: add e | 27 ; CHECK: add e |
| 23 ; ARM32-LABEL: Add | 28 ; ARM32-LABEL: Add |
| 24 ; ARM32: add r | 29 ; ARM32: add r |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ; ARM32: add r | 115 ; ARM32: add r |
| 111 | 116 |
| 112 define i32 @Sdiv(i32 %a, i32 %b) { | 117 define i32 @Sdiv(i32 %a, i32 %b) { |
| 113 entry: | 118 entry: |
| 114 %div = sdiv i32 %a, %b | 119 %div = sdiv i32 %a, %b |
| 115 ret i32 %div | 120 ret i32 %div |
| 116 } | 121 } |
| 117 ; CHECK-LABEL: Sdiv | 122 ; CHECK-LABEL: Sdiv |
| 118 ; CHECK: cdq | 123 ; CHECK: cdq |
| 119 ; CHECK: idiv e | 124 ; CHECK: idiv e |
| 125 ; |
| 120 ; ARM32-LABEL: Sdiv | 126 ; ARM32-LABEL: Sdiv |
| 121 ; TODO(jvoung) -- implement divide and check here. | 127 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 122 ; The lowering needs to check if the denominator is 0 and trap, since | 128 ; ARM32: bne [[LABEL:[0-9a-f]+]] |
| 123 ; ARM normally doesn't trap on divide by 0. | 129 ; ARM32: .word 0xe7fedef0 |
| 130 ; ARM32: [[LABEL]]: {{.*}} bl {{.*}} __divsi3 |
| 131 ; ARM32HWDIV-LABEL: Sdiv |
| 132 ; ARM32HWDIV: tst |
| 133 ; ARM32HWDIV: bne |
| 134 ; ARM32HWDIV: sdiv |
| 135 |
| 136 define i32 @SdivConst(i32 %a) { |
| 137 entry: |
| 138 %div = sdiv i32 %a, 219 |
| 139 ret i32 %div |
| 140 } |
| 141 ; CHECK-LABEL: SdivConst |
| 142 ; CHECK: cdq |
| 143 ; CHECK: idiv e |
| 144 ; |
| 145 ; ARM32-LABEL: SdivConst |
| 146 ; ARM32-NOT: tst |
| 147 ; ARM32: bl {{.*}} __divsi3 |
| 148 ; ARM32HWDIV-LABEL: SdivConst |
| 149 ; ARM32HWDIV-NOT: tst |
| 150 ; ARM32HWDIV: sdiv |
| 124 | 151 |
| 125 define i32 @Srem(i32 %a, i32 %b) { | 152 define i32 @Srem(i32 %a, i32 %b) { |
| 126 entry: | 153 entry: |
| 127 %rem = srem i32 %a, %b | 154 %rem = srem i32 %a, %b |
| 128 ret i32 %rem | 155 ret i32 %rem |
| 129 } | 156 } |
| 130 ; CHECK-LABEL: Srem | 157 ; CHECK-LABEL: Srem |
| 131 ; CHECK: cdq | 158 ; CHECK: cdq |
| 132 ; CHECK: idiv e | 159 ; CHECK: idiv e |
| 160 ; |
| 133 ; ARM32-LABEL: Srem | 161 ; ARM32-LABEL: Srem |
| 162 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 163 ; ARM32: bne |
| 164 ; ARM32: bl {{.*}} __modsi3 |
| 165 ; ARM32HWDIV-LABEL: Srem |
| 166 ; ARM32HWDIV: tst |
| 167 ; ARM32HWDIV: bne |
| 168 ; ARM32HWDIV: sdiv |
| 169 ; ARM32HWDIV: mls |
| 134 | 170 |
| 135 define i32 @Udiv(i32 %a, i32 %b) { | 171 define i32 @Udiv(i32 %a, i32 %b) { |
| 136 entry: | 172 entry: |
| 137 %div = udiv i32 %a, %b | 173 %div = udiv i32 %a, %b |
| 138 ret i32 %div | 174 ret i32 %div |
| 139 } | 175 } |
| 140 ; CHECK-LABEL: Udiv | 176 ; CHECK-LABEL: Udiv |
| 141 ; CHECK: div e | 177 ; CHECK: div e |
| 178 ; |
| 142 ; ARM32-LABEL: Udiv | 179 ; ARM32-LABEL: Udiv |
| 180 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 181 ; ARM32: bne |
| 182 ; ARM32: bl {{.*}} __udivsi3 |
| 183 ; ARM32HWDIV-LABEL: Udiv |
| 184 ; ARM32HWDIV: tst |
| 185 ; ARM32HWDIV: bne |
| 186 ; ARM32HWDIV: udiv |
| 143 | 187 |
| 144 define i32 @Urem(i32 %a, i32 %b) { | 188 define i32 @Urem(i32 %a, i32 %b) { |
| 145 entry: | 189 entry: |
| 146 %rem = urem i32 %a, %b | 190 %rem = urem i32 %a, %b |
| 147 ret i32 %rem | 191 ret i32 %rem |
| 148 } | 192 } |
| 149 ; CHECK-LABEL: Urem | 193 ; CHECK-LABEL: Urem |
| 150 ; CHECK: div e | 194 ; CHECK: div e |
| 195 ; |
| 151 ; ARM32-LABEL: Urem | 196 ; ARM32-LABEL: Urem |
| 197 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 198 ; ARM32: bne |
| 199 ; ARM32: bl {{.*}} __umodsi3 |
| 200 ; ARM32HWDIV-LABEL: Urem |
| 201 ; ARM32HWDIV: tst |
| 202 ; ARM32HWDIV: bne |
| 203 ; ARM32HWDIV: udiv |
| 204 ; ARM32HWDIV: mls |
| OLD | NEW |