Skip to content

Commit ac3ab9a

Browse files
committed
Add commuted and negative tests
Commuted case cos * tan and a negative test with mismatched X (tan(a) * cos(b))
1 parent 52e45f7 commit ac3ab9a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

llvm/test/Transforms/InstCombine/fmul-tan-cos.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,32 @@ define fp128 @fmul_tanfp128_cosfp128_reassoc(fp128 %a) {
105105
ret fp128 %res
106106
}
107107

108+
; commutativity
109+
define double @commutativity_cos_tan(double %a) {
110+
; CHECK-LABEL: define double @commutativity_cos_tan(
111+
; CHECK-SAME: double [[A:%.*]]) {
112+
; CHECK-NEXT: [[RES:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
113+
; CHECK-NEXT: ret double [[RES]]
114+
;
115+
%cos = call reassoc double @llvm.cos.f64(double %a)
116+
%tan = call reassoc double @llvm.tan.f64(double %a)
117+
%res = fmul reassoc double %cos, %tan
118+
ret double %res
119+
}
120+
121+
; negative test with mismatched value
122+
define double @tan_cos_value_mismatch(double %a, double %b) {
123+
; CHECK-LABEL: define double @tan_cos_value_mismatch(
124+
; CHECK-SAME: double [[A:%.*]], double [[B:%.*]]) {
125+
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @llvm.tan.f64(double [[A]])
126+
; CHECK-NEXT: [[COS:%.*]] = call reassoc double @llvm.cos.f64(double [[B]])
127+
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[TAN]], [[COS]]
128+
; CHECK-NEXT: ret double [[RES]]
129+
;
130+
%tan = call reassoc double @llvm.tan.f64(double %a)
131+
%cos = call reassoc double @llvm.cos.f64(double %b)
132+
%res = fmul reassoc double %tan, %cos
133+
ret double %res
134+
}
135+
108136
declare void @use(double)

0 commit comments

Comments
 (0)