Duncan Sands | ad20681 | 2011-05-03 19:53:10 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 2 | |
| 3 | define i1 @max1(i32 %x, i32 %y) { |
| 4 | ; CHECK: @max1 |
| 5 | %c = icmp sgt i32 %x, %y |
| 6 | %m = select i1 %c, i32 %x, i32 %y |
| 7 | %r = icmp slt i32 %m, %x |
| 8 | ret i1 %r |
| 9 | ; CHECK: ret i1 false |
| 10 | } |
| 11 | |
| 12 | define i1 @max2(i32 %x, i32 %y) { |
| 13 | ; CHECK: @max2 |
| 14 | %c = icmp sge i32 %x, %y |
| 15 | %m = select i1 %c, i32 %x, i32 %y |
| 16 | %r = icmp sge i32 %m, %x |
| 17 | ret i1 %r |
| 18 | ; CHECK: ret i1 true |
| 19 | } |
| 20 | |
| 21 | define i1 @max3(i32 %x, i32 %y) { |
| 22 | ; CHECK: @max3 |
| 23 | %c = icmp ugt i32 %x, %y |
| 24 | %m = select i1 %c, i32 %x, i32 %y |
| 25 | %r = icmp ult i32 %m, %x |
| 26 | ret i1 %r |
| 27 | ; CHECK: ret i1 false |
| 28 | } |
| 29 | |
| 30 | define i1 @max4(i32 %x, i32 %y) { |
| 31 | ; CHECK: @max4 |
| 32 | %c = icmp uge i32 %x, %y |
| 33 | %m = select i1 %c, i32 %x, i32 %y |
| 34 | %r = icmp uge i32 %m, %x |
| 35 | ret i1 %r |
| 36 | ; CHECK: ret i1 true |
| 37 | } |
| 38 | |
| 39 | define i1 @max5(i32 %x, i32 %y) { |
| 40 | ; CHECK: @max5 |
| 41 | %c = icmp sgt i32 %x, %y |
| 42 | %m = select i1 %c, i32 %x, i32 %y |
| 43 | %r = icmp sgt i32 %x, %m |
| 44 | ret i1 %r |
| 45 | ; CHECK: ret i1 false |
| 46 | } |
| 47 | |
| 48 | define i1 @max6(i32 %x, i32 %y) { |
| 49 | ; CHECK: @max6 |
| 50 | %c = icmp sge i32 %x, %y |
| 51 | %m = select i1 %c, i32 %x, i32 %y |
| 52 | %r = icmp sle i32 %x, %m |
| 53 | ret i1 %r |
| 54 | ; CHECK: ret i1 true |
| 55 | } |
| 56 | |
| 57 | define i1 @max7(i32 %x, i32 %y) { |
| 58 | ; CHECK: @max7 |
| 59 | %c = icmp ugt i32 %x, %y |
| 60 | %m = select i1 %c, i32 %x, i32 %y |
| 61 | %r = icmp ugt i32 %x, %m |
| 62 | ret i1 %r |
| 63 | ; CHECK: ret i1 false |
| 64 | } |
| 65 | |
| 66 | define i1 @max8(i32 %x, i32 %y) { |
| 67 | ; CHECK: @max8 |
| 68 | %c = icmp uge i32 %x, %y |
| 69 | %m = select i1 %c, i32 %x, i32 %y |
| 70 | %r = icmp ule i32 %x, %m |
| 71 | ret i1 %r |
| 72 | ; CHECK: ret i1 true |
| 73 | } |
| 74 | |
| 75 | define i1 @min1(i32 %x, i32 %y) { |
| 76 | ; CHECK: @min1 |
| 77 | %c = icmp sgt i32 %x, %y |
| 78 | %m = select i1 %c, i32 %y, i32 %x |
| 79 | %r = icmp sgt i32 %m, %x |
| 80 | ret i1 %r |
| 81 | ; CHECK: ret i1 false |
| 82 | } |
| 83 | |
| 84 | define i1 @min2(i32 %x, i32 %y) { |
| 85 | ; CHECK: @min2 |
| 86 | %c = icmp sge i32 %x, %y |
| 87 | %m = select i1 %c, i32 %y, i32 %x |
| 88 | %r = icmp sle i32 %m, %x |
| 89 | ret i1 %r |
| 90 | ; CHECK: ret i1 true |
| 91 | } |
| 92 | |
| 93 | define i1 @min3(i32 %x, i32 %y) { |
| 94 | ; CHECK: @min3 |
| 95 | %c = icmp ugt i32 %x, %y |
| 96 | %m = select i1 %c, i32 %y, i32 %x |
| 97 | %r = icmp ugt i32 %m, %x |
| 98 | ret i1 %r |
| 99 | ; CHECK: ret i1 false |
| 100 | } |
| 101 | |
| 102 | define i1 @min4(i32 %x, i32 %y) { |
| 103 | ; CHECK: @min4 |
| 104 | %c = icmp uge i32 %x, %y |
| 105 | %m = select i1 %c, i32 %y, i32 %x |
| 106 | %r = icmp ule i32 %m, %x |
| 107 | ret i1 %r |
| 108 | ; CHECK: ret i1 true |
| 109 | } |
| 110 | |
| 111 | define i1 @min5(i32 %x, i32 %y) { |
| 112 | ; CHECK: @min5 |
| 113 | %c = icmp sgt i32 %x, %y |
| 114 | %m = select i1 %c, i32 %y, i32 %x |
| 115 | %r = icmp slt i32 %x, %m |
| 116 | ret i1 %r |
| 117 | ; CHECK: ret i1 false |
| 118 | } |
| 119 | |
| 120 | define i1 @min6(i32 %x, i32 %y) { |
| 121 | ; CHECK: @min6 |
| 122 | %c = icmp sge i32 %x, %y |
| 123 | %m = select i1 %c, i32 %y, i32 %x |
| 124 | %r = icmp sge i32 %x, %m |
| 125 | ret i1 %r |
| 126 | ; CHECK: ret i1 true |
| 127 | } |
| 128 | |
| 129 | define i1 @min7(i32 %x, i32 %y) { |
| 130 | ; CHECK: @min7 |
| 131 | %c = icmp ugt i32 %x, %y |
| 132 | %m = select i1 %c, i32 %y, i32 %x |
| 133 | %r = icmp ult i32 %x, %m |
| 134 | ret i1 %r |
| 135 | ; CHECK: ret i1 false |
| 136 | } |
| 137 | |
| 138 | define i1 @min8(i32 %x, i32 %y) { |
| 139 | ; CHECK: @min8 |
| 140 | %c = icmp uge i32 %x, %y |
| 141 | %m = select i1 %c, i32 %y, i32 %x |
| 142 | %r = icmp uge i32 %x, %m |
| 143 | ret i1 %r |
| 144 | ; CHECK: ret i1 true |
| 145 | } |