File: frm-dependency.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 (124 lines) | stat: -rw-r--r-- 5,609 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
; RUN: llc -mtriple=riscv32 -mattr=+f,+d -stop-after=finalize-isel < %s \
; RUN:   | FileCheck -check-prefixes=RV32IF %s
; RUN: llc -mtriple=riscv64 -mattr=+f,+d -stop-after=finalize-isel < %s \
; RUN:   | FileCheck -check-prefixes=RV64IF %s

; Make sure an implicit FRM dependency is added to instructions with dynamic
; rounding.

define float @fadd_s(float %a, float %b) nounwind {
  ; RV32IF-LABEL: name: fadd_s
  ; RV32IF: bb.0 (%ir-block.0):
  ; RV32IF-NEXT:   liveins: $x10, $x11
  ; RV32IF-NEXT: {{  $}}
  ; RV32IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x11
  ; RV32IF-NEXT:   [[COPY1:%[0-9]+]]:gpr = COPY $x10
  ; RV32IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV32IF-NEXT:   [[FMV_W_X1:%[0-9]+]]:fpr32 = FMV_W_X [[COPY1]]
  ; RV32IF-NEXT:   %4:fpr32 = nofpexcept FADD_S killed [[FMV_W_X1]], killed [[FMV_W_X]], 7, implicit $frm
  ; RV32IF-NEXT:   [[FMV_X_W:%[0-9]+]]:gpr = FMV_X_W killed %4
  ; RV32IF-NEXT:   $x10 = COPY [[FMV_X_W]]
  ; RV32IF-NEXT:   PseudoRET implicit $x10
  ; RV64IF-LABEL: name: fadd_s
  ; RV64IF: bb.0 (%ir-block.0):
  ; RV64IF-NEXT:   liveins: $x10, $x11
  ; RV64IF-NEXT: {{  $}}
  ; RV64IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x11
  ; RV64IF-NEXT:   [[COPY1:%[0-9]+]]:gpr = COPY $x10
  ; RV64IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV64IF-NEXT:   [[FMV_W_X1:%[0-9]+]]:fpr32 = FMV_W_X [[COPY1]]
  ; RV64IF-NEXT:   %4:fpr32 = nofpexcept FADD_S killed [[FMV_W_X1]], killed [[FMV_W_X]], 7, implicit $frm
  ; RV64IF-NEXT:   [[FMV_X_W:%[0-9]+]]:gpr = FMV_X_W killed %4
  ; RV64IF-NEXT:   $x10 = COPY [[FMV_X_W]]
  ; RV64IF-NEXT:   PseudoRET implicit $x10
  %1 = fadd float %a, %b
  ret float %1
}

declare float @llvm.fma.f32(float, float, float)

define float @fmadd_s(float %a, float %b, float %c) nounwind {
  ; RV32IF-LABEL: name: fmadd_s
  ; RV32IF: bb.0 (%ir-block.0):
  ; RV32IF-NEXT:   liveins: $x10, $x11, $x12
  ; RV32IF-NEXT: {{  $}}
  ; RV32IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x12
  ; RV32IF-NEXT:   [[COPY1:%[0-9]+]]:gpr = COPY $x11
  ; RV32IF-NEXT:   [[COPY2:%[0-9]+]]:gpr = COPY $x10
  ; RV32IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV32IF-NEXT:   [[FMV_W_X1:%[0-9]+]]:fpr32 = FMV_W_X [[COPY1]]
  ; RV32IF-NEXT:   [[FMV_W_X2:%[0-9]+]]:fpr32 = FMV_W_X [[COPY2]]
  ; RV32IF-NEXT:   %6:fpr32 = nofpexcept FMADD_S killed [[FMV_W_X2]], killed [[FMV_W_X1]], killed [[FMV_W_X]], 7, implicit $frm
  ; RV32IF-NEXT:   [[FMV_X_W:%[0-9]+]]:gpr = FMV_X_W killed %6
  ; RV32IF-NEXT:   $x10 = COPY [[FMV_X_W]]
  ; RV32IF-NEXT:   PseudoRET implicit $x10
  ; RV64IF-LABEL: name: fmadd_s
  ; RV64IF: bb.0 (%ir-block.0):
  ; RV64IF-NEXT:   liveins: $x10, $x11, $x12
  ; RV64IF-NEXT: {{  $}}
  ; RV64IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x12
  ; RV64IF-NEXT:   [[COPY1:%[0-9]+]]:gpr = COPY $x11
  ; RV64IF-NEXT:   [[COPY2:%[0-9]+]]:gpr = COPY $x10
  ; RV64IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV64IF-NEXT:   [[FMV_W_X1:%[0-9]+]]:fpr32 = FMV_W_X [[COPY1]]
  ; RV64IF-NEXT:   [[FMV_W_X2:%[0-9]+]]:fpr32 = FMV_W_X [[COPY2]]
  ; RV64IF-NEXT:   %6:fpr32 = nofpexcept FMADD_S killed [[FMV_W_X2]], killed [[FMV_W_X1]], killed [[FMV_W_X]], 7, implicit $frm
  ; RV64IF-NEXT:   [[FMV_X_W:%[0-9]+]]:gpr = FMV_X_W killed %6
  ; RV64IF-NEXT:   $x10 = COPY [[FMV_X_W]]
  ; RV64IF-NEXT:   PseudoRET implicit $x10
  %1 = call float @llvm.fma.f32(float %a, float %b, float %c)
  ret float %1
}

; This uses rtz instead of dyn rounding mode so shouldn't have an FRM dependncy.
define i32 @fcvt_w_s(float %a) nounwind {
  ; RV32IF-LABEL: name: fcvt_w_s
  ; RV32IF: bb.0 (%ir-block.0):
  ; RV32IF-NEXT:   liveins: $x10
  ; RV32IF-NEXT: {{  $}}
  ; RV32IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x10
  ; RV32IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV32IF-NEXT:   %2:gpr = nofpexcept FCVT_W_S killed [[FMV_W_X]], 1
  ; RV32IF-NEXT:   $x10 = COPY %2
  ; RV32IF-NEXT:   PseudoRET implicit $x10
  ; RV64IF-LABEL: name: fcvt_w_s
  ; RV64IF: bb.0 (%ir-block.0):
  ; RV64IF-NEXT:   liveins: $x10
  ; RV64IF-NEXT: {{  $}}
  ; RV64IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x10
  ; RV64IF-NEXT:   [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
  ; RV64IF-NEXT:   %2:gpr = nofpexcept FCVT_W_S killed [[FMV_W_X]], 1
  ; RV64IF-NEXT:   $x10 = COPY %2
  ; RV64IF-NEXT:   PseudoRET implicit $x10
  %1 = fptosi float %a to i32
  ret i32 %1
}

; This doesn't use a rounding mode since i32 can be represented exactly as a
; double.
define double @fcvt_d_w(i32 %a) nounwind {
  ; RV32IF-LABEL: name: fcvt_d_w
  ; RV32IF: bb.0 (%ir-block.0):
  ; RV32IF-NEXT:   liveins: $x10
  ; RV32IF-NEXT: {{  $}}
  ; RV32IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x10
  ; RV32IF-NEXT:   %1:fpr64 = nofpexcept FCVT_D_W [[COPY]]
  ; RV32IF-NEXT:   FSD killed %1, %stack.0, 0 :: (store (s64) into %stack.0)
  ; RV32IF-NEXT:   [[LW:%[0-9]+]]:gpr = LW %stack.0, 0 :: (load (s32) from %stack.0, align 8)
  ; RV32IF-NEXT:   [[LW1:%[0-9]+]]:gpr = LW %stack.0, 4 :: (load (s32) from %stack.0 + 4, basealign 8)
  ; RV32IF-NEXT:   $x10 = COPY [[LW]]
  ; RV32IF-NEXT:   $x11 = COPY [[LW1]]
  ; RV32IF-NEXT:   PseudoRET implicit $x10, implicit $x11
  ; RV64IF-LABEL: name: fcvt_d_w
  ; RV64IF: bb.0 (%ir-block.0):
  ; RV64IF-NEXT:   liveins: $x10
  ; RV64IF-NEXT: {{  $}}
  ; RV64IF-NEXT:   [[COPY:%[0-9]+]]:gpr = COPY $x10
  ; RV64IF-NEXT:   %1:fpr64 = nofpexcept FCVT_D_W [[COPY]]
  ; RV64IF-NEXT:   [[FMV_X_D:%[0-9]+]]:gpr = FMV_X_D killed %1
  ; RV64IF-NEXT:   $x10 = COPY [[FMV_X_D]]
  ; RV64IF-NEXT:   PseudoRET implicit $x10
  %1 = sitofp i32 %a to double
  ret double %1
}