Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | ; This is a very early test that just checks the representation of i32 |
| 2 | ; arithmetic instructions. No assembly tests are done. |
| 3 | |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 4 | ; REQUIRES: allow_dump |
| 5 | |
Jan Voung | 0faec4c | 2014-11-05 17:29:56 -0800 | [diff] [blame] | 6 | ; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 7 | |
| 8 | define i32 @Add(i32 %a, i32 %b) { |
| 9 | ; CHECK: define i32 @Add |
| 10 | entry: |
| 11 | %add = add i32 %b, %a |
| 12 | ; CHECK: add |
| 13 | tail call void @Use(i32 %add) |
| 14 | ; CHECK: call Use |
| 15 | ret i32 %add |
| 16 | } |
| 17 | |
| 18 | declare void @Use(i32) |
| 19 | |
| 20 | define i32 @And(i32 %a, i32 %b) { |
| 21 | ; CHECK: define i32 @And |
| 22 | entry: |
| 23 | %and = and i32 %b, %a |
| 24 | ; CHECK: and |
| 25 | tail call void @Use(i32 %and) |
| 26 | ; CHECK: call Use |
| 27 | ret i32 %and |
| 28 | } |
| 29 | |
| 30 | define i32 @Or(i32 %a, i32 %b) { |
| 31 | ; CHECK: define i32 @Or |
| 32 | entry: |
| 33 | %or = or i32 %b, %a |
| 34 | ; CHECK: or |
| 35 | tail call void @Use(i32 %or) |
| 36 | ; CHECK: call Use |
| 37 | ret i32 %or |
| 38 | } |
| 39 | |
| 40 | define i32 @Xor(i32 %a, i32 %b) { |
| 41 | ; CHECK: define i32 @Xor |
| 42 | entry: |
| 43 | %xor = xor i32 %b, %a |
| 44 | ; CHECK: xor |
| 45 | tail call void @Use(i32 %xor) |
| 46 | ; CHECK: call Use |
| 47 | ret i32 %xor |
| 48 | } |
| 49 | |
| 50 | define i32 @Sub(i32 %a, i32 %b) { |
| 51 | ; CHECK: define i32 @Sub |
| 52 | entry: |
| 53 | %sub = sub i32 %a, %b |
| 54 | ; CHECK: sub |
| 55 | tail call void @Use(i32 %sub) |
| 56 | ; CHECK: call Use |
| 57 | ret i32 %sub |
| 58 | } |
| 59 | |
| 60 | define i32 @Mul(i32 %a, i32 %b) { |
| 61 | ; CHECK: define i32 @Mul |
| 62 | entry: |
| 63 | %mul = mul i32 %b, %a |
| 64 | ; CHECK: imul |
| 65 | tail call void @Use(i32 %mul) |
| 66 | ; CHECK: call Use |
| 67 | ret i32 %mul |
| 68 | } |
| 69 | |
| 70 | define i32 @Sdiv(i32 %a, i32 %b) { |
| 71 | ; CHECK: define i32 @Sdiv |
| 72 | entry: |
| 73 | %div = sdiv i32 %a, %b |
| 74 | ; CHECK: cdq |
| 75 | ; CHECK: idiv |
| 76 | tail call void @Use(i32 %div) |
| 77 | ; CHECK: call Use |
| 78 | ret i32 %div |
| 79 | } |
| 80 | |
| 81 | define i32 @Srem(i32 %a, i32 %b) { |
| 82 | ; CHECK: define i32 @Srem |
| 83 | entry: |
| 84 | %rem = srem i32 %a, %b |
| 85 | ; CHECK: cdq |
| 86 | ; CHECK: idiv |
| 87 | tail call void @Use(i32 %rem) |
| 88 | ; CHECK: call Use |
| 89 | ret i32 %rem |
| 90 | } |
| 91 | |
| 92 | define i32 @Udiv(i32 %a, i32 %b) { |
| 93 | ; CHECK: define i32 @Udiv |
| 94 | entry: |
| 95 | %div = udiv i32 %a, %b |
| 96 | ; CHECK: div |
| 97 | tail call void @Use(i32 %div) |
| 98 | ; CHECK: call Use |
| 99 | ret i32 %div |
| 100 | } |
| 101 | |
| 102 | define i32 @Urem(i32 %a, i32 %b) { |
| 103 | ; CHECK: define i32 @Urem |
| 104 | entry: |
| 105 | %rem = urem i32 %a, %b |
| 106 | ; CHECK: div |
| 107 | tail call void @Use(i32 %rem) |
| 108 | ; CHECK: call Use |
| 109 | ret i32 %rem |
| 110 | } |
| 111 | |
Jim Stichnoth | ef8cf0e | 2014-08-26 22:16:29 -0700 | [diff] [blame] | 112 | ; Check for a valid addressing mode in the x86-32 mul instruction when |
| 113 | ; the second source operand is an immediate. |
| 114 | define i64 @MulImm() { |
| 115 | entry: |
| 116 | %mul = mul i64 3, 4 |
| 117 | ret i64 %mul |
| 118 | } |
| 119 | ; CHECK-LABEL: MulImm |
| 120 | ; CHECK-NOT: mul {{[0-9]+}} |