Skip to content

Commit e550e27

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

File tree

1 file changed

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

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ 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+
2025
; cos(-x) -> cos(x);
2126

2227
define double @cos_negated_arg(double %x) {
@@ -100,6 +105,41 @@ define float @cosf_unary_negated_arg_FMF(float %x) {
100105
ret float %r
101106
}
102107

108+
; cos(fabs(x)) -> cos(x)
109+
110+
define double @cos_unary_fabs_arg(double %x) {
111+
; ANY-LABEL: @cos_unary_fabs_arg(
112+
; ANY-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
113+
; ANY-NEXT: [[R:%.*]] = call double @cos(double [[FABS]])
114+
; ANY-NEXT: ret double [[R]]
115+
;
116+
%fabs = tail call double @llvm.fabs.f64(double %x)
117+
%r = call double @cos(double %fabs)
118+
ret double %r
119+
}
120+
121+
define float @cosf_unary_fabs_arg(float %x) {
122+
; ANY-LABEL: @cosf_unary_fabs_arg(
123+
; ANY-NEXT: [[FABS:%.*]] = tail call float @llvm.fabs.f32(float [[X:%.*]])
124+
; ANY-NEXT: [[R:%.*]] = call float @cosf(float [[FABS]])
125+
; ANY-NEXT: ret float [[R]]
126+
;
127+
%fabs = tail call float @llvm.fabs.f32(float %x)
128+
%r = call float @cosf(float %fabs)
129+
ret float %r
130+
}
131+
132+
define float @cosf_unary_fabs_arg_FMF(float %x) {
133+
; ANY-LABEL: @cosf_unary_fabs_arg_FMF(
134+
; ANY-NEXT: [[FABS:%.*]] = tail call float @llvm.fabs.f32(float [[X:%.*]])
135+
; ANY-NEXT: [[R:%.*]] = call reassoc nnan float @cosf(float [[FABS]])
136+
; ANY-NEXT: ret float [[R]]
137+
;
138+
%fabs = tail call float @llvm.fabs.f32(float %x)
139+
%r = call nnan reassoc float @cosf(float %fabs)
140+
ret float %r
141+
}
142+
103143
; sin(-x) -> -sin(x);
104144

105145
define double @sin_negated_arg(double %x) {

0 commit comments

Comments
 (0)