Nick Lewycky | a3a68bd | 2006-09-02 19:40:38 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | grep -v declare | not grep fail && |
Nick Lewycky | 802fe27 | 2006-10-22 19:53:27 +0000 | [diff] [blame^] | 2 | ; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | grep -v declare | grep -c pass | grep 4 |
Nick Lewycky | 05450ae | 2006-08-28 22:44:55 +0000 | [diff] [blame] | 3 | |
| 4 | void %test1(int %x) { |
| 5 | entry: |
| 6 | %A = seteq int %x, 0 |
| 7 | br bool %A, label %then.1, label %else.1 |
| 8 | then.1: |
| 9 | %B = seteq int %x, 1 |
| 10 | br bool %B, label %then.2, label %else.1 |
| 11 | then.2: |
| 12 | call void (...)* %fail( ) |
| 13 | ret void |
| 14 | else.1: |
| 15 | ret void |
| 16 | } |
| 17 | |
| 18 | void %test2(int %x) { |
| 19 | entry: |
| 20 | %A = seteq int %x, 0 |
| 21 | %B = seteq int %x, 1 |
| 22 | br bool %A, label %then.1, label %else.1 |
| 23 | then.1: |
| 24 | br bool %B, label %then.2, label %else.1 |
| 25 | then.2: |
| 26 | call void (...)* %fail( ) |
| 27 | ret void |
| 28 | else.1: |
| 29 | ret void |
| 30 | } |
| 31 | |
| 32 | void %test3(int %x) { |
| 33 | entry: |
| 34 | %A = seteq int %x, 0 |
| 35 | %B = seteq int %x, 1 |
| 36 | br bool %A, label %then.1, label %else.1 |
| 37 | then.1: |
| 38 | br bool %B, label %then.2, label %else.1 |
| 39 | then.2: |
| 40 | call void (...)* %fail( ) |
| 41 | ret void |
| 42 | else.1: |
| 43 | ret void |
| 44 | } |
| 45 | |
| 46 | void %test4(int %x, int %y) { |
| 47 | entry: |
| 48 | %A = seteq int %x, 0 |
| 49 | %B = seteq int %y, 0 |
| 50 | %C = and bool %A, %B |
| 51 | br bool %C, label %then.1, label %else.1 |
| 52 | then.1: |
| 53 | %D = seteq int %x, 0 |
| 54 | br bool %D, label %then.2, label %else.2 |
| 55 | then.2: |
| 56 | %E = seteq int %y, 0 |
| 57 | br bool %E, label %else.1, label %else.2 |
| 58 | else.1: |
| 59 | ret void |
| 60 | else.2: |
| 61 | call void (...)* %fail( ) |
| 62 | ret void |
| 63 | } |
| 64 | |
| 65 | void %test5(int %x) { |
| 66 | entry: |
| 67 | %A = seteq int %x, 0 |
| 68 | br bool %A, label %then.1, label %else.1 |
| 69 | then.1: |
| 70 | ret void |
| 71 | then.2: |
| 72 | call void (...)* %fail( ) |
| 73 | ret void |
| 74 | else.1: |
| 75 | %B = seteq int %x, 0 |
| 76 | br bool %B, label %then.2, label %then.1 |
| 77 | } |
| 78 | |
| 79 | void %test6(int %x, int %y) { |
| 80 | entry: |
| 81 | %A = seteq int %x, 0 |
| 82 | %B = seteq int %y, 0 |
| 83 | %C = or bool %A, %B |
| 84 | br bool %C, label %then.1, label %else.1 |
| 85 | then.1: |
| 86 | ret void |
| 87 | then.2: |
| 88 | call void (...)* %fail( ) |
| 89 | ret void |
| 90 | else.1: |
| 91 | %D = seteq int %x, 0 |
| 92 | br bool %D, label %then.2, label %else.2 |
| 93 | else.2: |
| 94 | %E = setne int %y, 0 |
| 95 | br bool %E, label %then.1, label %then.2 |
| 96 | } |
| 97 | |
| 98 | void %test7(int %x) { |
| 99 | entry: |
| 100 | %A = setne int %x, 0 |
| 101 | %B = xor bool %A, true |
| 102 | br bool %B, label %then.1, label %else.1 |
| 103 | then.1: |
| 104 | %C = seteq int %x, 1 |
| 105 | br bool %C, label %then.2, label %else.1 |
| 106 | then.2: |
| 107 | call void (...)* %fail( ) |
| 108 | ret void |
| 109 | else.1: |
| 110 | ret void |
| 111 | } |
| 112 | |
| 113 | void %test8(int %x) { |
| 114 | entry: |
| 115 | %A = add int %x, 1 |
| 116 | %B = seteq int %x, 0 |
| 117 | br bool %B, label %then.1, label %then.2 |
| 118 | then.1: |
| 119 | %C = seteq int %A, 1 |
| 120 | br bool %C, label %then.2, label %else.2 |
| 121 | then.2: |
| 122 | ret void |
| 123 | else.2: |
| 124 | call void (...)* %fail( ) |
| 125 | ret void |
| 126 | } |
| 127 | |
Nick Lewycky | a3a68bd | 2006-09-02 19:40:38 +0000 | [diff] [blame] | 128 | void %test9(int %y, int %z) { |
| 129 | entry: |
| 130 | %x = add int %y, %z |
| 131 | %A = seteq int %y, 3 |
| 132 | %B = seteq int %z, 5 |
| 133 | %C = and bool %A, %B |
| 134 | br bool %C, label %cond_true, label %return |
| 135 | |
| 136 | cond_true: |
| 137 | %D = seteq int %x, 8 |
| 138 | br bool %D, label %then, label %oops |
| 139 | |
| 140 | then: |
| 141 | call void (...)* %pass( ) |
| 142 | ret void |
| 143 | |
| 144 | oops: |
| 145 | call void (...)* %fail( ) |
| 146 | ret void |
| 147 | |
| 148 | return: |
| 149 | ret void |
| 150 | } |
| 151 | |
Nick Lewycky | 802fe27 | 2006-10-22 19:53:27 +0000 | [diff] [blame^] | 152 | void %test10() { |
| 153 | entry: |
| 154 | %A = alloca int |
| 155 | %B = seteq int* %A, null |
| 156 | br bool %B, label %cond_true, label %cond_false |
| 157 | |
| 158 | cond_true: |
| 159 | call void (...)* %fail ( ) |
| 160 | ret void |
| 161 | |
| 162 | cond_false: |
| 163 | call void (...)* %pass ( ) |
| 164 | ret void |
| 165 | } |
| 166 | |
Nick Lewycky | a3a68bd | 2006-09-02 19:40:38 +0000 | [diff] [blame] | 167 | void %switch1(int %x) { |
| 168 | entry: |
| 169 | %A = seteq int %x, 10 |
| 170 | br bool %A, label %return, label %cond_false |
| 171 | |
| 172 | cond_false: |
| 173 | switch int %x, label %return [ |
| 174 | int 9, label %then1 |
| 175 | int 10, label %then2 |
| 176 | ] |
| 177 | |
| 178 | then1: |
| 179 | call void (...)* %pass( ) |
| 180 | ret void |
| 181 | |
| 182 | then2: |
| 183 | call void (...)* %fail( ) |
| 184 | ret void |
| 185 | |
| 186 | return: |
| 187 | ret void |
| 188 | } |
| 189 | |
| 190 | void %switch2(int %x) { |
| 191 | entry: |
| 192 | %A = seteq int %x, 10 |
| 193 | br bool %A, label %return, label %cond_false |
| 194 | |
| 195 | cond_false: |
| 196 | switch int %x, label %return [ |
| 197 | int 8, label %then1 |
| 198 | int 9, label %then1 |
| 199 | int 10, label %then1 |
| 200 | ] |
| 201 | |
| 202 | then1: |
| 203 | %B = setne int %x, 8 |
| 204 | br bool %B, label %then2, label %return |
| 205 | |
| 206 | then2: |
| 207 | call void (...)* %pass( ) |
| 208 | ret void |
| 209 | |
| 210 | return: |
| 211 | ret void |
| 212 | } |
| 213 | |
| 214 | void %switch3(int %x) { |
| 215 | entry: |
| 216 | %A = seteq int %x, 10 |
| 217 | br bool %A, label %return, label %cond_false |
| 218 | |
| 219 | cond_false: |
| 220 | switch int %x, label %return [ |
| 221 | int 9, label %then1 |
| 222 | int 10, label %then1 |
| 223 | ] |
| 224 | |
| 225 | then1: |
| 226 | %B = seteq int %x, 9 |
| 227 | br bool %B, label %return, label %oops |
| 228 | |
| 229 | oops: |
| 230 | call void (...)* %fail( ) |
| 231 | ret void |
| 232 | |
| 233 | return: |
| 234 | ret void |
| 235 | } |
| 236 | |
| 237 | void %switch4(int %x) { |
| 238 | entry: |
| 239 | %A = seteq int %x, 10 |
| 240 | br bool %A, label %then1, label %cond_false |
| 241 | |
| 242 | cond_false: |
| 243 | switch int %x, label %default [ |
| 244 | int 9, label %then1 |
| 245 | int 10, label %then2 |
| 246 | ] |
| 247 | |
| 248 | then1: |
| 249 | ret void |
| 250 | |
| 251 | then2: |
| 252 | ret void |
| 253 | |
| 254 | default: |
| 255 | %B = seteq int %x, 9 |
| 256 | br bool %B, label %oops, label %then1 |
| 257 | |
| 258 | oops: |
| 259 | call void (...)* %fail( ) |
| 260 | ret void |
| 261 | } |
| 262 | |
| 263 | void %select1(int %x) { |
| 264 | entry: |
| 265 | %A = seteq int %x, 10 |
| 266 | %B = select bool %A, int 1, int 2 |
| 267 | %C = seteq int %B, 1 |
| 268 | br bool %C, label %then, label %else |
| 269 | |
| 270 | then: |
| 271 | br bool %A, label %return, label %oops |
| 272 | |
| 273 | else: |
| 274 | br bool %A, label %oops, label %return |
| 275 | |
| 276 | oops: |
| 277 | call void (...)* %fail( ) |
| 278 | ret void |
| 279 | |
| 280 | return: |
| 281 | ret void |
| 282 | } |
| 283 | |
| 284 | void %select2(int %x) { |
| 285 | entry: |
| 286 | %A = seteq int %x, 10 |
| 287 | %B = select bool %A, int 1, int 2 |
| 288 | %C = seteq int %B, 1 |
| 289 | br bool %A, label %then, label %else |
| 290 | |
| 291 | then: |
| 292 | br bool %C, label %return, label %oops |
| 293 | |
| 294 | else: |
| 295 | br bool %C, label %oops, label %return |
| 296 | |
| 297 | oops: |
| 298 | call void (...)* %fail( ) |
| 299 | ret void |
| 300 | |
| 301 | return: |
| 302 | ret void |
| 303 | } |
Nick Lewycky | 05450ae | 2006-08-28 22:44:55 +0000 | [diff] [blame] | 304 | |
| 305 | declare void %fail(...) |
| 306 | |
| 307 | declare void %pass(...) |