File: pseudo_cmov_lower-fp16.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (97 lines) | stat: -rw-r--r-- 3,597 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
; RUN: llc < %s -mtriple=i386-linux-gnu -mattr=+avx512fp16 -mattr=+avx512vl -o - | FileCheck %s

; This test checks that only a single je gets generated in the final code
; for lowering the CMOV pseudos that get created for this IR.
; CHECK-LABEL: foo1:
; CHECK: je
; CHECK-NOT: je
define <8 x half> @foo1(i32 %v1, <8 x half> %v2, <8 x half> %v3, <8 x half> %v4) nounwind {
entry:
  %cmp = icmp eq i32 %v1, 0
  %t1 = select i1 %cmp, <8 x half> %v2, <8 x half> %v3
  %t2 = select i1 %cmp, <8 x half> %v3, <8 x half> %v4
  %sub = fsub <8 x half> %t1, %t2
  ret <8 x half> %sub
}

; This test checks that only a single ja gets generated in the final code
; for lowering the CMOV pseudos that get created for this IR. This combines
; all the supported types together into one long string of selects based
; on the same condition.
; CHECK-LABEL: foo2:
; CHECK: ja
; CHECK-NOT: ja
define void @foo2(i32 %v1,
                  half %v32, half %v33,
                  <8 x half> %v52, <8 x half> %v53,
                  <16 x half> %v122, <16 x half> %v123,
                  <32 x half> %v132, <32 x half> %v133,
                  i8 * %dst) nounwind {
entry:
  %add.ptr31 = getelementptr inbounds i8, i8* %dst, i32 2
  %a31 = bitcast i8* %add.ptr31 to half*

  %add.ptr51 = getelementptr inbounds i8, i8* %dst, i32 4
  %a51 = bitcast i8* %add.ptr51 to <8 x half>*

  %add.ptr121 = getelementptr inbounds i8, i8* %dst, i32 20
  %a121 = bitcast i8* %add.ptr121 to <16 x half>*

  %add.ptr131 = getelementptr inbounds i8, i8* %dst, i32 52
  %a131 = bitcast i8* %add.ptr131 to <32 x half>*

  ; These operations are necessary, because select of two single use loads
  ; ends up getting optimized into a select of two leas, followed by a
  ; single load of the selected address.

  %t33 = fadd half %v33, %v32
  %t53 = fadd <8 x half> %v53, %v52
  %t123 = fadd <16 x half> %v123, %v122
  %t133 = fadd <32 x half> %v133, %v132

  %cmp = icmp ugt i32 %v1, 31
  %t31 = select i1 %cmp, half %v32, half %t33
  %t51 = select i1 %cmp, <8 x half> %v52, <8 x half> %t53
  %t121 = select i1 %cmp, <16 x half> %v122, <16 x half> %t123
  %t131 = select i1 %cmp, <32 x half> %v132, <32 x half> %t133

  store half %t31, half* %a31, align 2
  store <8 x half> %t51, <8 x half>* %a51, align 16
  store <16 x half> %t121, <16 x half>* %a121, align 32
  store <32 x half> %t131, <32 x half>* %a131, align 64

  ret void
}

; This test checks that only a single jne gets generated in the final code
; for lowering the CMOV pseudos that get created for this IR.
define dso_local <32 x half> @foo3(<32 x half> %a, <32 x half> %b, i1 zeroext %sign) local_unnamed_addr #0 {
; CHECK-LABEL: foo3:
; CHECK: jne
; CHECK-NOT: jne
entry:
  %spec.select = select i1 %sign, <32 x half> %a, <32 x half> %b
  ret <32 x half> %spec.select
}

; This test checks that only a single jne gets generated in the final code
; for lowering the CMOV pseudos that get created for this IR.
define dso_local <16 x half> @foo4(<16 x half> %a, <16 x half> %b, i1 zeroext %sign) local_unnamed_addr #0 {
; CHECK-LABEL: foo4:
; CHECK: jne
; CHECK-NOT: jne
entry:
  %spec.select = select i1 %sign, <16 x half> %a, <16 x half> %b
  ret <16 x half> %spec.select
}

; This test checks that only a single jne gets generated in the final code
; for lowering the CMOV pseudos that get created for this IR.
define dso_local <8 x half> @foo5(<8 x half> %a, <8 x half> %b, i1 zeroext %sign) local_unnamed_addr #0 {
; CHECK-LABEL: foo5:
; CHECK: jne
; CHECK-NOT: jne
entry:
  %spec.select = select i1 %sign, <8 x half> %a, <8 x half> %b
  ret <8 x half> %spec.select
}