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
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
define double @fdiv_sin_cos(double %a) {
; CHECK-LABEL: @fdiv_sin_cos(
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[A:%.*]])
; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
; CHECK-NEXT: ret double [[DIV]]
;
%1 = call double @llvm.sin.f64(double %a)
%2 = call double @llvm.cos.f64(double %a)
%div = fdiv double %1, %2
ret double %div
}
define double @fdiv_strict_sin_strict_cos_reassoc(double %a) {
; CHECK-LABEL: @fdiv_strict_sin_strict_cos_reassoc(
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[A:%.*]])
; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
; CHECK-NEXT: ret double [[DIV]]
;
%1 = call double @llvm.sin.f64(double %a)
%2 = call reassoc double @llvm.cos.f64(double %a)
%div = fdiv double %1, %2
ret double %div
}
define double @fdiv_reassoc_sin_strict_cos_strict(double %a, i32* dereferenceable(2) %dummy) {
; CHECK-LABEL: @fdiv_reassoc_sin_strict_cos_strict(
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
; CHECK-NEXT: ret double [[TAN]]
;
%1 = call double @llvm.sin.f64(double %a)
%2 = call double @llvm.cos.f64(double %a)
%div = fdiv reassoc double %1, %2
ret double %div
}
define double @fdiv_reassoc_sin_reassoc_cos_strict(double %a) {
; CHECK-LABEL: @fdiv_reassoc_sin_reassoc_cos_strict(
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
; CHECK-NEXT: ret double [[TAN]]
;
%1 = call reassoc double @llvm.sin.f64(double %a)
%2 = call double @llvm.cos.f64(double %a)
%div = fdiv reassoc double %1, %2
ret double %div
}
define double @fdiv_sin_cos_reassoc_multiple_uses(double %a) {
; CHECK-LABEL: @fdiv_sin_cos_reassoc_multiple_uses(
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.sin.f64(double [[A:%.*]])
; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc double [[TMP1]], [[TMP2]]
; CHECK-NEXT: call void @use(double [[TMP2]])
; CHECK-NEXT: ret double [[DIV]]
;
%1 = call reassoc double @llvm.sin.f64(double %a)
%2 = call reassoc double @llvm.cos.f64(double %a)
%div = fdiv reassoc double %1, %2
call void @use(double %2)
ret double %div
}
define double @fdiv_sin_cos_reassoc(double %a) {
; CHECK-LABEL: @fdiv_sin_cos_reassoc(
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
; CHECK-NEXT: ret double [[TAN]]
;
%1 = call reassoc double @llvm.sin.f64(double %a)
%2 = call reassoc double @llvm.cos.f64(double %a)
%div = fdiv reassoc double %1, %2
ret double %div
}
define float @fdiv_sinf_cosf_reassoc(float %a) {
; CHECK-LABEL: @fdiv_sinf_cosf_reassoc(
; CHECK-NEXT: [[TANF:%.*]] = call reassoc float @tanf(float [[A:%.*]]) #1
; CHECK-NEXT: ret float [[TANF]]
;
%1 = call reassoc float @llvm.sin.f32(float %a)
%2 = call reassoc float @llvm.cos.f32(float %a)
%div = fdiv reassoc float %1, %2
ret float %div
}
define fp128 @fdiv_sinfp128_cosfp128_reassoc(fp128 %a) {
; CHECK-LABEL: @fdiv_sinfp128_cosfp128_reassoc(
; CHECK-NEXT: [[TANL:%.*]] = call reassoc fp128 @tanl(fp128 [[A:%.*]]) #1
; CHECK-NEXT: ret fp128 [[TANL]]
;
%1 = call reassoc fp128 @llvm.sin.fp128(fp128 %a)
%2 = call reassoc fp128 @llvm.cos.fp128(fp128 %a)
%div = fdiv reassoc fp128 %1, %2
ret fp128 %div
}
declare double @llvm.sin.f64(double) #1
declare float @llvm.sin.f32(float) #1
declare fp128 @llvm.sin.fp128(fp128) #1
declare double @llvm.cos.f64(double) #1
declare float @llvm.cos.f32(float) #1
declare fp128 @llvm.cos.fp128(fp128) #1
declare void @use(double)
attributes #0 = { nounwind readnone speculatable }
attributes #1 = { nounwind readnone }
|