• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs -o - %s | FileCheck %s
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
7declare void @bar()
8
9@var = global i32 0
10
11define i32 @test_multiflag(i32 %n, i32 %m, i32 %o) {
12; CHECK-LABEL: test_multiflag:
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
18; CHECK: cset {{[xw][0-9]+}}, ne
19
20; CHECK: mov [[RHSCOPY:w[0-9]+]], [[RHS]]
21; CHECK: mov [[LHSCOPY:w[0-9]+]], [[LHS]]
22
23  store i32 %val, i32* @var
24
25  call void @bar()
26; CHECK: bl bar
27
28  ; Currently, the comparison is emitted again. An MSR/MRS pair would also be
29  ; acceptable, but assuming the call preserves NZCV is not.
30  br i1 %test, label %iftrue, label %iffalse
31; CHECK: cmp [[LHSCOPY]], [[RHSCOPY]]
32; CHECK: b.eq
33
34iftrue:
35  ret i32 42
36iffalse:
37  ret i32 0
38}
39