xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-setcc-int-to-fp-combine.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -asm-verbose=false -mtriple=arm64-apple-ios | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @foo(<4 x float> %val, <4 x float> %test) nounwind {
4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo:
5*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: fcmeq.4s  v0, v0, v1
6*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: fmov.4s v1, #1.00000000
7*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: and.16b v0, v0, v1
8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
9*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp oeq <4 x float> %val, %test
10*9880d681SAndroid Build Coastguard Worker  %ext = zext <4 x i1> %cmp to <4 x i32>
11*9880d681SAndroid Build Coastguard Worker  %result = sitofp <4 x i32> %ext to <4 x float>
12*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %result
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker; Make sure the operation doesn't try to get folded when the sizes don't match,
15*9880d681SAndroid Build Coastguard Worker; as that ends up crashing later when trying to form a bitcast operation for
16*9880d681SAndroid Build Coastguard Worker; the folded nodes.
17*9880d681SAndroid Build Coastguard Workerdefine void @foo1(<4 x float> %val, <4 x float> %test, <4 x double>* %p) nounwind {
18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo1:
19*9880d681SAndroid Build Coastguard Worker; CHECK: movi.4s
20*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf.2d
21*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf.2d
22*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp oeq <4 x float> %val, %test
23*9880d681SAndroid Build Coastguard Worker  %ext = zext <4 x i1> %cmp to <4 x i32>
24*9880d681SAndroid Build Coastguard Worker  %result = sitofp <4 x i32> %ext to <4 x double>
25*9880d681SAndroid Build Coastguard Worker  store <4 x double> %result, <4 x double>* %p
26*9880d681SAndroid Build Coastguard Worker  ret void
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; Fold explicit AND operations when the constant isn't a splat of a single
30*9880d681SAndroid Build Coastguard Worker; scalar value like what the zext creates.
31*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @foo2(<4 x float> %val, <4 x float> %test) nounwind {
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: lCPI2_0:
33*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1065353216
34*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0
35*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1065353216
36*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0
37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo2:
38*9880d681SAndroid Build Coastguard Worker; CHECK: adrp  x8, lCPI2_0@PAGE
39*9880d681SAndroid Build Coastguard Worker; CHECK: ldr q2, [x8, lCPI2_0@PAGEOFF]
40*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  fcmeq.4s  v0, v0, v1
41*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  and.16b v0, v0, v2
42*9880d681SAndroid Build Coastguard Worker  %cmp = fcmp oeq <4 x float> %val, %test
43*9880d681SAndroid Build Coastguard Worker  %ext = zext <4 x i1> %cmp to <4 x i32>
44*9880d681SAndroid Build Coastguard Worker  %and = and <4 x i32> %ext, <i32 255, i32 256, i32 257, i32 258>
45*9880d681SAndroid Build Coastguard Worker  %result = sitofp <4 x i32> %and to <4 x float>
46*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %result
47*9880d681SAndroid Build Coastguard Worker}
48