Tim Northover | b4ddc08 | 2014-05-30 10:09:59 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=aarch64-none-linux-gnu -aarch64-atomic-cfg-tidy=0 -verify-machineinstrs -o - %s | FileCheck %s |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 2 | |
| 3 | ; LLVM should be able to cope with multiple uses of the same flag-setting |
| 4 | ; instruction at different points of a routine. Either by rematerializing the |
| 5 | ; compare or by saving and restoring the flag register. |
| 6 | |
| 7 | declare void @bar() |
| 8 | |
| 9 | @var = global i32 0 |
| 10 | |
| 11 | define i32 @test_multiflag(i32 %n, i32 %m, i32 %o) { |
Stephen Lin | f799e3f | 2013-07-13 20:38:47 +0000 | [diff] [blame] | 12 | ; CHECK-LABEL: test_multiflag: |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 13 | |
| 14 | %test = icmp ne i32 %n, %m |
| 15 | ; CHECK: cmp [[LHS:w[0-9]+]], [[RHS:w[0-9]+]] |
| 16 | |
| 17 | %val = zext i1 %test to i32 |
Tim Northover | ee20caa | 2014-05-12 18:04:06 +0000 | [diff] [blame] | 18 | ; CHECK: cset {{[xw][0-9]+}}, ne |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 19 | |
| 20 | store i32 %val, i32* @var |
| 21 | |
| 22 | call void @bar() |
| 23 | ; CHECK: bl bar |
| 24 | |
| 25 | ; Currently, the comparison is emitted again. An MSR/MRS pair would also be |
| 26 | ; acceptable, but assuming the call preserves NZCV is not. |
| 27 | br i1 %test, label %iftrue, label %iffalse |
| 28 | ; CHECK: cmp [[LHS]], [[RHS]] |
| 29 | ; CHECK: b.eq |
| 30 | |
| 31 | iftrue: |
| 32 | ret i32 42 |
| 33 | iffalse: |
| 34 | ret i32 0 |
| 35 | } |