Skip to content

Commit b74d412

Browse files
committed
[Transforms] Add pre-commit tests (NFC)
1 parent 5282202 commit b74d412

File tree

1 file changed

+79
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+79
-0
lines changed

llvm/test/Transforms/InstCombine/cos-1.ll

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ declare float @llvm.sin.f32(float)
1717
declare double @tan(double)
1818
declare fp128 @tanl(fp128)
1919

20+
declare double @fabs(double)
21+
declare double @llvm.fabs.f64(double)
22+
declare float @fabsf(float)
23+
declare float @llvm.fabs.f32(float)
24+
25+
declare double @llvm.copysign(double, double)
26+
declare float @llvm.copysign.f32(float, float)
27+
2028
; cos(-x) -> cos(x);
2129

2230
define double @cos_negated_arg(double %x) {
@@ -100,6 +108,77 @@ define float @cosf_unary_negated_arg_FMF(float %x) {
100108
ret float %r
101109
}
102110

111+
; cos(fabs(x)) -> cos(x)
112+
113+
define double @cos_unary_fabs_arg(double %x) {
114+
; ANY-LABEL: @cos_unary_fabs_arg(
115+
; ANY-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
116+
; ANY-NEXT: [[R:%.*]] = call double @cos(double [[FABS]])
117+
; ANY-NEXT: ret double [[R]]
118+
;
119+
%fabs = tail call double @llvm.fabs.f64(double %x)
120+
%r = call double @cos(double %fabs)
121+
ret double %r
122+
}
123+
124+
define float @cosf_unary_fabs_arg(float %x) {
125+
; ANY-LABEL: @cosf_unary_fabs_arg(
126+
; ANY-NEXT: [[FABS:%.*]] = tail call float @llvm.fabs.f32(float [[X:%.*]])
127+
; ANY-NEXT: [[R:%.*]] = call float @cosf(float [[FABS]])
128+
; ANY-NEXT: ret float [[R]]
129+
;
130+
%fabs = tail call float @llvm.fabs.f32(float %x)
131+
%r = call float @cosf(float %fabs)
132+
ret float %r
133+
}
134+
135+
define float @cosf_unary_fabs_arg_FMF(float %x) {
136+
; ANY-LABEL: @cosf_unary_fabs_arg_FMF(
137+
; ANY-NEXT: [[FABS:%.*]] = tail call float @llvm.fabs.f32(float [[X:%.*]])
138+
; ANY-NEXT: [[R:%.*]] = call reassoc nnan float @cosf(float [[FABS]])
139+
; ANY-NEXT: ret float [[R]]
140+
;
141+
%fabs = tail call float @llvm.fabs.f32(float %x)
142+
%r = call nnan reassoc float @cosf(float %fabs)
143+
ret float %r
144+
}
145+
146+
; cos(copysign(x, y)) -> cos(x)
147+
148+
define double @cos_copysign_arg(double %x, double %y) {
149+
; ANY-LABEL: @cos_copysign_arg(
150+
; ANY-NEXT: [[COPYSIGN:%.*]] = tail call double @llvm.copysign.f64(double [[X:%.*]], double [[Y:%.*]])
151+
; ANY-NEXT: [[R:%.*]] = call double @cos(double [[COPYSIGN]])
152+
; ANY-NEXT: ret double [[R]]
153+
;
154+
%copysign = tail call double @llvm.copysign(double %x, double %y)
155+
%r = call double @cos(double %copysign)
156+
ret double %r
157+
}
158+
159+
160+
define float @cosf_unary_copysign_arg(float %x) {
161+
; ANY-LABEL: @cosf_unary_copysign_arg(
162+
; ANY-NEXT: [[COPYSIGN:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
163+
; ANY-NEXT: [[R:%.*]] = call float @cosf(float [[COPYSIGN]])
164+
; ANY-NEXT: ret float [[R]]
165+
;
166+
%copysign = tail call float @llvm.copysign.f32(float %x, float 1.0)
167+
%r = call float @cosf(float %copysign)
168+
ret float %r
169+
}
170+
171+
define float @cosf_copysign_arg_FMF(float %x, float %y) {
172+
; ANY-LABEL: @cosf_copysign_arg_FMF(
173+
; ANY-NEXT: [[COPYSIGN:%.*]] = tail call float @llvm.copysign.f32(float [[X:%.*]], float [[Y:%.*]])
174+
; ANY-NEXT: [[R:%.*]] = call reassoc nnan float @cosf(float [[COPYSIGN]])
175+
; ANY-NEXT: ret float [[R]]
176+
;
177+
%copysign = tail call float @llvm.copysign.f32(float %x, float %y)
178+
%r = call nnan reassoc float @cosf(float %copysign)
179+
ret float %r
180+
}
181+
103182
; sin(-x) -> -sin(x);
104183

105184
define double @sin_negated_arg(double %x) {

0 commit comments

Comments
 (0)