1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s
4 define double @fdiv_sin_cos(double %a) {
5 ; CHECK-LABEL: @fdiv_sin_cos(
6 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[A:%.*]])
7 ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.cos.f64(double [[A]])
8 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
9 ; CHECK-NEXT: ret double [[DIV]]
11 %1 = call double @llvm.sin.f64(double %a)
12 %2 = call double @llvm.cos.f64(double %a)
13 %div = fdiv double %1, %2
17 define double @fdiv_strict_sin_strict_cos_reassoc(double %a) {
18 ; CHECK-LABEL: @fdiv_strict_sin_strict_cos_reassoc(
19 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.sin.f64(double [[A:%.*]])
20 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.cos.f64(double [[A]])
21 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[TMP1]], [[TMP2]]
22 ; CHECK-NEXT: ret double [[DIV]]
24 %1 = call double @llvm.sin.f64(double %a)
25 %2 = call reassoc double @llvm.cos.f64(double %a)
26 %div = fdiv double %1, %2
30 define double @fdiv_reassoc_sin_strict_cos_strict(double %a, ptr dereferenceable(2) %dummy) {
31 ; CHECK-LABEL: @fdiv_reassoc_sin_strict_cos_strict(
32 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #[[ATTR1:[0-9]+]]
33 ; CHECK-NEXT: ret double [[TAN]]
35 %1 = call double @llvm.sin.f64(double %a)
36 %2 = call double @llvm.cos.f64(double %a)
37 %div = fdiv reassoc double %1, %2
41 define double @fdiv_reassoc_sin_reassoc_cos_strict(double %a) {
42 ; CHECK-LABEL: @fdiv_reassoc_sin_reassoc_cos_strict(
43 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #[[ATTR1]]
44 ; CHECK-NEXT: ret double [[TAN]]
46 %1 = call reassoc double @llvm.sin.f64(double %a)
47 %2 = call double @llvm.cos.f64(double %a)
48 %div = fdiv reassoc double %1, %2
52 define double @fdiv_sin_cos_reassoc_multiple_uses(double %a) {
53 ; CHECK-LABEL: @fdiv_sin_cos_reassoc_multiple_uses(
54 ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.sin.f64(double [[A:%.*]])
55 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.cos.f64(double [[A]])
56 ; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc double [[TMP1]], [[TMP2]]
57 ; CHECK-NEXT: call void @use(double [[TMP2]])
58 ; CHECK-NEXT: ret double [[DIV]]
60 %1 = call reassoc double @llvm.sin.f64(double %a)
61 %2 = call reassoc double @llvm.cos.f64(double %a)
62 %div = fdiv reassoc double %1, %2
63 call void @use(double %2)
67 define double @fdiv_sin_cos_reassoc(double %a) {
68 ; CHECK-LABEL: @fdiv_sin_cos_reassoc(
69 ; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @tan(double [[A:%.*]]) #[[ATTR1]]
70 ; CHECK-NEXT: ret double [[TAN]]
72 %1 = call reassoc double @llvm.sin.f64(double %a)
73 %2 = call reassoc double @llvm.cos.f64(double %a)
74 %div = fdiv reassoc double %1, %2
78 define float @fdiv_sinf_cosf_reassoc(float %a) {
79 ; CHECK-LABEL: @fdiv_sinf_cosf_reassoc(
80 ; CHECK-NEXT: [[TANF:%.*]] = call reassoc float @tanf(float [[A:%.*]]) #[[ATTR1]]
81 ; CHECK-NEXT: ret float [[TANF]]
83 %1 = call reassoc float @llvm.sin.f32(float %a)
84 %2 = call reassoc float @llvm.cos.f32(float %a)
85 %div = fdiv reassoc float %1, %2
89 define fp128 @fdiv_sinfp128_cosfp128_reassoc(fp128 %a) {
90 ; CHECK-LABEL: @fdiv_sinfp128_cosfp128_reassoc(
91 ; CHECK-NEXT: [[TANL:%.*]] = call reassoc fp128 @tanl(fp128 [[A:%.*]]) #[[ATTR1]]
92 ; CHECK-NEXT: ret fp128 [[TANL]]
94 %1 = call reassoc fp128 @llvm.sin.fp128(fp128 %a)
95 %2 = call reassoc fp128 @llvm.cos.fp128(fp128 %a)
96 %div = fdiv reassoc fp128 %1, %2
100 declare double @llvm.sin.f64(double) #1
101 declare float @llvm.sin.f32(float) #1
102 declare fp128 @llvm.sin.fp128(fp128) #1
104 declare double @llvm.cos.f64(double) #1
105 declare float @llvm.cos.f32(float) #1
106 declare fp128 @llvm.cos.fp128(fp128) #1
108 declare void @use(double)
110 attributes #0 = { nounwind readnone speculatable }
111 attributes #1 = { nounwind readnone }