xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/regress-f128csel-flags.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; We used to not mark NZCV as being used in the continuation basic-block
4*9880d681SAndroid Build Coastguard Worker; when lowering a 128-bit "select" to branches. This meant a subsequent use
5*9880d681SAndroid Build Coastguard Worker; of the same flags gave an internal fault here.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workerdeclare void @foo(fp128)
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine double @test_f128csel_flags(i32 %lhs, fp128 %a, fp128 %b) nounwind {
10*9880d681SAndroid Build Coastguard Worker; CHECK: test_f128csel_flags
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker    %tst = icmp ne i32 %lhs, 42
13*9880d681SAndroid Build Coastguard Worker    %val = select i1 %tst, fp128 %a, fp128 %b
14*9880d681SAndroid Build Coastguard Worker; CHECK: cmp w0, #42
15*9880d681SAndroid Build Coastguard Worker; CHECK: b.eq .LBB0
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker    call void @foo(fp128 %val)
18*9880d681SAndroid Build Coastguard Worker    %retval = select i1 %tst, double 4.0, double 5.0
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker    ; It's also reasonably important that the actual fcsel comes before the
21*9880d681SAndroid Build Coastguard Worker    ; function call since bl may corrupt NZCV. We were doing the right thing anyway,
22*9880d681SAndroid Build Coastguard Worker    ; but just as well test it while we're here.
23*9880d681SAndroid Build Coastguard Worker; CHECK: fcsel {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, ne
24*9880d681SAndroid Build Coastguard Worker; CHECK: bl foo
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker    ret double %retval
27*9880d681SAndroid Build Coastguard Worker}
28