1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 define double @fdiv_cos_sin(double %a) {
5 ; CHECK-LABEL: @fdiv_cos_sin(
6 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.cos.f64(double [[A:%.*]])
7 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.sin.f64(double [[A]])
8 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
9 ; CHECK-NEXT: ret double [[DIV]]
11 %1 = call double @llvm.cos.f64(double %a)
12 %2 = call double @llvm.sin.f64(double %a)
13 %div = fdiv double %1, %2
17 define double @fdiv_strict_cos_strict_sin_reassoc(double %a) {
18 ; CHECK-LABEL: @fdiv_strict_cos_strict_sin_reassoc(
19 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.cos.f64(double [[A:%.*]])
20 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
21 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
22 ; CHECK-NEXT: ret double [[DIV]]
24 %1 = call double @llvm.cos.f64(double %a)
25 %2 = call reassoc double @llvm.sin.f64(double %a)
26 %div = fdiv double %1, %2
30 define double @fdiv_reassoc_cos_strict_sin_strict(double %a, i32* dereferenceable(2) %dummy) {
31 ; CHECK-LABEL: @fdiv_reassoc_cos_strict_sin_strict(
32 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
33 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc double 1.000000e+00, [[TAN]]
34 ; CHECK-NEXT: ret double [[TMP1]]
36 %1 = call double @llvm.cos.f64(double %a)
37 %2 = call double @llvm.sin.f64(double %a)
38 %div = fdiv reassoc double %1, %2
42 define double @fdiv_reassoc_cos_reassoc_sin_strict(double %a) {
43 ; CHECK-LABEL: @fdiv_reassoc_cos_reassoc_sin_strict(
44 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
45 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc double 1.000000e+00, [[TAN]]
46 ; CHECK-NEXT: ret double [[TMP1]]
48 %1 = call reassoc double @llvm.cos.f64(double %a)
49 %2 = call double @llvm.sin.f64(double %a)
50 %div = fdiv reassoc double %1, %2
54 define double @fdiv_cos_sin_reassoc_multiple_uses(double %a) {
55 ; CHECK-LABEL: @fdiv_cos_sin_reassoc_multiple_uses(
56 ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.cos.f64(double [[A:%.*]])
57 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
58 ; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc double [[TMP1]], [[TMP2]]
59 ; CHECK-NEXT: call void @use(double [[TMP2]])
60 ; CHECK-NEXT: ret double [[DIV]]
62 %1 = call reassoc double @llvm.cos.f64(double %a)
63 %2 = call reassoc double @llvm.sin.f64(double %a)
64 %div = fdiv reassoc double %1, %2
65 call void @use(double %2)
69 define double @fdiv_cos_sin_reassoc(double %a) {
70 ; CHECK-LABEL: @fdiv_cos_sin_reassoc(
71 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #1
72 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc double 1.000000e+00, [[TAN]]
73 ; CHECK-NEXT: ret double [[TMP1]]
75 %1 = call reassoc double @llvm.cos.f64(double %a)
76 %2 = call reassoc double @llvm.sin.f64(double %a)
77 %div = fdiv reassoc double %1, %2
81 define half @fdiv_cosf16_sinf16_reassoc(half %a) {
82 ; CHECK-LABEL: @fdiv_cosf16_sinf16_reassoc(
83 ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc half @llvm.cos.f16(half [[A:%.*]])
84 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc half @llvm.sin.f16(half [[A]])
85 ; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc half [[TMP1]], [[TMP2]]
86 ; CHECK-NEXT: ret half [[DIV]]
88 %1 = call reassoc half @llvm.cos.f16(half %a)
89 %2 = call reassoc half @llvm.sin.f16(half %a)
90 %div = fdiv reassoc half %1, %2
94 define float @fdiv_cosf_sinf_reassoc(float %a) {
95 ; CHECK-LABEL: @fdiv_cosf_sinf_reassoc(
96 ; CHECK-NEXT: [[TANF:%.*]] = call reassoc float @tanf(float [[A:%.*]]) #1
97 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc float 1.000000e+00, [[TANF]]
98 ; CHECK-NEXT: ret float [[TMP1]]
100 %1 = call reassoc float @llvm.cos.f32(float %a)
101 %2 = call reassoc float @llvm.sin.f32(float %a)
102 %div = fdiv reassoc float %1, %2
106 define fp128 @fdiv_cosfp128_sinfp128_reassoc(fp128 %a) {
107 ; CHECK-LABEL: @fdiv_cosfp128_sinfp128_reassoc(
108 ; CHECK-NEXT: [[TANL:%.*]] = call reassoc fp128 @tanl(fp128 [[A:%.*]]) #1
109 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc fp128 0xL00000000000000003FFF000000000000, [[TANL]]
110 ; CHECK-NEXT: ret fp128 [[TMP1]]
112 %1 = call reassoc fp128 @llvm.cos.fp128(fp128 %a)
113 %2 = call reassoc fp128 @llvm.sin.fp128(fp128 %a)
114 %div = fdiv reassoc fp128 %1, %2
118 declare half @llvm.cos.f16(half) #1
119 declare float @llvm.cos.f32(float) #1
120 declare double @llvm.cos.f64(double) #1
121 declare fp128 @llvm.cos.fp128(fp128) #1
123 declare half @llvm.sin.f16(half) #1
124 declare float @llvm.sin.f32(float) #1
125 declare double @llvm.sin.f64(double) #1
126 declare fp128 @llvm.sin.fp128(fp128) #1
128 declare void @use(double)
130 attributes #0 = { nounwind readnone speculatable }
131 attributes #1 = { nounwind readnone }