Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 1 | ; 1. Trivial smoke test of compare and branch, with multiple basic |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 2 | ; blocks. |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 3 | ; 2. For a conditional branch on a constant boolean value, make sure |
| 4 | ; we don't lower to a cmp instructions with an immediate as the first |
| 5 | ; source operand. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 6 | |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 7 | ; REQUIRES: allow_dump |
| 8 | |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 9 | ; RUN: %p2i -i %s --args -O2 --verbose inst -threads=0 | FileCheck %s |
| 10 | ; RUN: %p2i -i %s --args -Om1 --verbose inst -threads=0 | FileCheck %s |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 11 | |
| 12 | define i32 @simple_cond_branch(i32 %foo, i32 %bar) { |
| 13 | entry: |
| 14 | %r1 = icmp eq i32 %foo, %bar |
| 15 | br i1 %r1, label %Equal, label %Unequal |
| 16 | Equal: |
| 17 | ret i32 %foo |
| 18 | Unequal: |
| 19 | ret i32 %bar |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 20 | ; CHECK-LABEL: simple_cond_branch |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 21 | ; CHECK: br i1 %r1, label %Equal, label %Unequal |
| 22 | ; CHECK: Equal: |
| 23 | ; CHECK: ret i32 %foo |
| 24 | ; CHECK: Unequal: |
| 25 | ; CHECK: ret i32 %bar |
| 26 | } |
| 27 | |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 28 | define internal i32 @test_br_const() { |
| 29 | __0: |
Jim Stichnoth | cabfa30 | 2014-09-03 15:19:12 -0700 | [diff] [blame] | 30 | br i1 true, label %__1, label %__2 |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 31 | __1: |
| 32 | ret i32 21 |
| 33 | __2: |
| 34 | ret i32 43 |
| 35 | } |
| 36 | ; CHECK-LABEL: test_br_const |
| 37 | ; CHECK-NOT: cmp {{[0-9]*}}, |