| OLD | NEW |
| 1 ; This checks the correctness of the lowering code for the small | 1 ; This checks the correctness of the lowering code for the small |
| 2 ; integer variants of sdiv and srem. | 2 ; integer variants of sdiv and srem. |
| 3 | 3 |
| 4 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s | 4 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s |
| 5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s | 5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s |
| 6 | 6 |
| 7 define i32 @sdiv_i8(i32 %a.i32, i32 %b.i32) { | 7 define internal i32 @sdiv_i8(i32 %a.i32, i32 %b.i32) { |
| 8 entry: | 8 entry: |
| 9 %a = trunc i32 %a.i32 to i8 | 9 %a = trunc i32 %a.i32 to i8 |
| 10 %b = trunc i32 %b.i32 to i8 | 10 %b = trunc i32 %b.i32 to i8 |
| 11 %res = sdiv i8 %a, %b | 11 %res = sdiv i8 %a, %b |
| 12 %res.i32 = zext i8 %res to i32 | 12 %res.i32 = zext i8 %res to i32 |
| 13 ret i32 %res.i32 | 13 ret i32 %res.i32 |
| 14 ; CHECK-LABEL: sdiv_i8 | 14 ; CHECK-LABEL: sdiv_i8 |
| 15 ; CHECK: cbw | 15 ; CHECK: cbw |
| 16 ; CHECK: idiv | 16 ; CHECK: idiv |
| 17 } | 17 } |
| 18 | 18 |
| 19 define i32 @sdiv_i16(i32 %a.i32, i32 %b.i32) { | 19 define internal i32 @sdiv_i16(i32 %a.i32, i32 %b.i32) { |
| 20 entry: | 20 entry: |
| 21 %a = trunc i32 %a.i32 to i16 | 21 %a = trunc i32 %a.i32 to i16 |
| 22 %b = trunc i32 %b.i32 to i16 | 22 %b = trunc i32 %b.i32 to i16 |
| 23 %res = sdiv i16 %a, %b | 23 %res = sdiv i16 %a, %b |
| 24 %res.i32 = zext i16 %res to i32 | 24 %res.i32 = zext i16 %res to i32 |
| 25 ret i32 %res.i32 | 25 ret i32 %res.i32 |
| 26 ; CHECK-LABEL: sdiv_i16 | 26 ; CHECK-LABEL: sdiv_i16 |
| 27 ; CHECK: cwd | 27 ; CHECK: cwd |
| 28 ; CHECK: idiv | 28 ; CHECK: idiv |
| 29 } | 29 } |
| 30 | 30 |
| 31 define i32 @sdiv_i32(i32 %a, i32 %b) { | 31 define internal i32 @sdiv_i32(i32 %a, i32 %b) { |
| 32 entry: | 32 entry: |
| 33 %res = sdiv i32 %a, %b | 33 %res = sdiv i32 %a, %b |
| 34 ret i32 %res | 34 ret i32 %res |
| 35 ; CHECK-LABEL: sdiv_i32 | 35 ; CHECK-LABEL: sdiv_i32 |
| 36 ; CHECK: cdq | 36 ; CHECK: cdq |
| 37 ; CHECK: idiv | 37 ; CHECK: idiv |
| 38 } | 38 } |
| 39 | 39 |
| 40 define i32 @srem_i8(i32 %a.i32, i32 %b.i32) { | 40 define internal i32 @srem_i8(i32 %a.i32, i32 %b.i32) { |
| 41 entry: | 41 entry: |
| 42 %a = trunc i32 %a.i32 to i8 | 42 %a = trunc i32 %a.i32 to i8 |
| 43 %b = trunc i32 %b.i32 to i8 | 43 %b = trunc i32 %b.i32 to i8 |
| 44 %res = srem i8 %a, %b | 44 %res = srem i8 %a, %b |
| 45 %res.i32 = zext i8 %res to i32 | 45 %res.i32 = zext i8 %res to i32 |
| 46 ret i32 %res.i32 | 46 ret i32 %res.i32 |
| 47 ; CHECK-LABEL: srem_i8 | 47 ; CHECK-LABEL: srem_i8 |
| 48 ; CHECK: cbw | 48 ; CHECK: cbw |
| 49 ; CHECK: idiv | 49 ; CHECK: idiv |
| 50 } | 50 } |
| 51 | 51 |
| 52 define i32 @srem_i16(i32 %a.i32, i32 %b.i32) { | 52 define internal i32 @srem_i16(i32 %a.i32, i32 %b.i32) { |
| 53 entry: | 53 entry: |
| 54 %a = trunc i32 %a.i32 to i16 | 54 %a = trunc i32 %a.i32 to i16 |
| 55 %b = trunc i32 %b.i32 to i16 | 55 %b = trunc i32 %b.i32 to i16 |
| 56 %res = srem i16 %a, %b | 56 %res = srem i16 %a, %b |
| 57 %res.i32 = zext i16 %res to i32 | 57 %res.i32 = zext i16 %res to i32 |
| 58 ret i32 %res.i32 | 58 ret i32 %res.i32 |
| 59 ; CHECK-LABEL: srem_i16 | 59 ; CHECK-LABEL: srem_i16 |
| 60 ; CHECK: cwd | 60 ; CHECK: cwd |
| 61 ; CHECK: idiv | 61 ; CHECK: idiv |
| 62 } | 62 } |
| 63 | 63 |
| 64 define i32 @srem_i32(i32 %a, i32 %b) { | 64 define internal i32 @srem_i32(i32 %a, i32 %b) { |
| 65 entry: | 65 entry: |
| 66 %res = srem i32 %a, %b | 66 %res = srem i32 %a, %b |
| 67 ret i32 %res | 67 ret i32 %res |
| 68 ; CHECK-LABEL: srem_i32 | 68 ; CHECK-LABEL: srem_i32 |
| 69 ; CHECK: cdq | 69 ; CHECK: cdq |
| 70 ; CHECK: idiv | 70 ; CHECK: idiv |
| 71 } | 71 } |
| OLD | NEW |