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 update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
; These tests choose arbitrarily between float and double,
; and between uge and olt, to give reasonble coverage
; without combinatorial explosion.
declare float @llvm.fabs.f32(float)
declare float @llvm.sqrt.f32(float)
declare double @llvm.powi.f64(double,i32)
declare float @llvm.exp.f32(float)
declare float @llvm.minnum.f32(float, float)
declare float @llvm.maxnum.f32(float, float)
declare double @llvm.exp2.f64(double)
declare float @llvm.fma.f32(float,float,float)
declare void @expect_equal(i1,i1)
define i1 @orderedLessZeroTree(float,float,float,float) {
; CHECK-LABEL: @orderedLessZeroTree(
; CHECK: ret i1 true
;
%square = fmul float %0, %0
%abs = call float @llvm.fabs.f32(float %1)
%sqrt = call float @llvm.sqrt.f32(float %2)
%fma = call float @llvm.fma.f32(float %3, float %3, float %sqrt)
%div = fdiv float %square, %abs
%rem = frem float %sqrt, %fma
%add = fadd float %div, %rem
%uge = fcmp uge float %add, 0.000000e+00
ret i1 %uge
}
define i1 @orderedLessZeroExpExt(float) {
; CHECK-LABEL: @orderedLessZeroExpExt(
; CHECK: ret i1 true
;
%a = call float @llvm.exp.f32(float %0)
%b = fpext float %a to double
%uge = fcmp uge double %b, 0.000000e+00
ret i1 %uge
}
define i1 @orderedLessZeroExp2Trunc(double) {
; CHECK-LABEL: @orderedLessZeroExp2Trunc(
; CHECK: ret i1 false
;
%a = call double @llvm.exp2.f64(double %0)
%b = fptrunc double %a to float
%olt = fcmp olt float %b, 0.000000e+00
ret i1 %olt
}
define i1 @orderedLessZeroPowi(double,double) {
; CHECK-LABEL: @orderedLessZeroPowi(
; CHECK: ret i1 false
;
; Even constant exponent
%a = call double @llvm.powi.f64(double %0, i32 2)
%square = fmul double %1, %1
; Odd constant exponent with provably non-negative base
%b = call double @llvm.powi.f64(double %square, i32 3)
%c = fadd double %a, %b
%olt = fcmp olt double %b, 0.000000e+00
ret i1 %olt
}
define i1 @orderedLessZeroUIToFP(i32) {
; CHECK-LABEL: @orderedLessZeroUIToFP(
; CHECK: ret i1 true
;
%a = uitofp i32 %0 to float
%uge = fcmp uge float %a, 0.000000e+00
ret i1 %uge
}
define i1 @orderedLessZeroSelect(float, float) {
; CHECK-LABEL: @orderedLessZeroSelect(
; CHECK: ret i1 true
;
%a = call float @llvm.exp.f32(float %0)
%b = call float @llvm.fabs.f32(float %1)
%c = fcmp olt float %0, %1
%d = select i1 %c, float %a, float %b
%e = fadd float %d, 1.0
%uge = fcmp uge float %e, 0.000000e+00
ret i1 %uge
}
define i1 @orderedLessZeroMinNum(float, float) {
; CHECK-LABEL: @orderedLessZeroMinNum(
; CHECK: ret i1 true
;
%a = call float @llvm.exp.f32(float %0)
%b = call float @llvm.fabs.f32(float %1)
%c = call float @llvm.minnum.f32(float %a, float %b)
%uge = fcmp uge float %c, 0.000000e+00
ret i1 %uge
}
define i1 @orderedLessZeroMaxNum(float, float) {
; CHECK-LABEL: @orderedLessZeroMaxNum(
; CHECK: ret i1 true
;
%a = call float @llvm.exp.f32(float %0)
%b = call float @llvm.maxnum.f32(float %a, float %1)
%uge = fcmp uge float %b, 0.000000e+00
ret i1 %uge
}
define i1 @nonans1(double %in1, double %in2) {
; CHECK-LABEL: @nonans1(
; CHECK: ret i1 false
;
%cmp = fcmp nnan uno double %in1, %in2
ret i1 %cmp
}
define i1 @nonans2(double %in1, double %in2) {
; CHECK-LABEL: @nonans2(
; CHECK: ret i1 true
;
%cmp = fcmp nnan ord double %in1, %in2
ret i1 %cmp
}
|