File: constrained.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (125 lines) | stat: -rw-r--r-- 4,883 bytes parent folder | download | duplicates (12)
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
125
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=instcombine %s | FileCheck %s

; Treatment of operation with unused result.

; If operation does not raise exceptions, it may be removed even in strict mode.
define float @f_unused_precise() #0 {
; CHECK-LABEL: @f_unused_precise(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 1.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fadd.f32(float 1.0, float 1.0, metadata !"round.upward", metadata !"fpexcept.strict") #0
  ret float 1.0
}

; If operation raises exceptions, it cannot be removed in strict mode.
define float @f_unused_strict() #0 {
; CHECK-LABEL: @f_unused_strict(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 1.000000e+00, float 3.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0:[0-9]+]]
; CHECK-NEXT:    ret float 1.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
  ret float 1.0
}

; If operation raises exceptions, it can be removed in non-strict mode.
define float @f_unused_ignore() #0 {
; CHECK-LABEL: @f_unused_ignore(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 1.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.towardzero", metadata !"fpexcept.ignore") #0
  ret float 1.0
}

; If operation raises exceptions, it can be removed in non-strict mode even if rounding mode is dynamic.
define float @f_unused_dynamic_ignore() #0 {
; CHECK-LABEL: @f_unused_dynamic_ignore(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 1.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
  ret float 1.0
}

; If operation raises exceptions, it can be removed in "maytrap" mode.
define float @f_unused_maytrap() #0 {
; CHECK-LABEL: @f_unused_maytrap(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 1.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
  ret float 1.0
}

; Constant evaluation.

; If operation does not raise exceptions, it may be folded even in strict mode.
define float @f_eval_precise() #0 {
; CHECK-LABEL: @f_eval_precise(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 2.000000e+00
;
entry:
  %result = call float @llvm.experimental.constrained.fadd.f32(float 1.0, float 1.0, metadata !"round.upward", metadata !"fpexcept.strict") #0
  ret float %result
}

; If operation raises exceptions, it cannot be folded in strict mode.
define float @f_eval_strict() #0 {
; CHECK-LABEL: @f_eval_strict(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 1.000000e+00, float 3.000000e+00, metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR0]]
; CHECK-NEXT:    ret float [[RESULT]]
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.upward", metadata !"fpexcept.strict") #0
  ret float %result
}

; If operation raises exceptions, it can be folded in non-strict mode.
define float @f_eval_ignore() #0 {
; CHECK-LABEL: @f_eval_ignore(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 0x3FD5555540000000
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.downward", metadata !"fpexcept.ignore") #0
  ret float %result
}

; if result is imprecise, it cannot be folded if rounding mode is dynamic.
define float @f_eval_dynamic_ignore() #0 {
; CHECK-LABEL: @f_eval_dynamic_ignore(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 1.000000e+00, float 3.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]]
; CHECK-NEXT:    ret float [[RESULT]]
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
  ret float %result
}

; If result is imprecise and rounding mode is not dynamic, operation can be folded in "maytrap" mode.
define float @f_eval_maytrap() #0 {
; CHECK-LABEL: @f_eval_maytrap(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    ret float 0x3FD5555560000000
;
entry:
  %result = call float @llvm.experimental.constrained.fdiv.f32(float 1.0, float 3.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
  ret float %result
}


declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
declare float @llvm.experimental.constrained.fdiv.f32(float, float, metadata, metadata)

attributes #0 = { strictfp }