Skip to content

Commit 52e45f7

Browse files
committed
Use m_Deferred instead m_Specific
The tests are fixed after change
1 parent 3ce32a0 commit 52e45f7

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ Instruction *InstCombinerImpl::foldFMulReassoc(BinaryOperator &I) {
950950
// tan(X) * cos(X) -> sin(X)
951951
if (match(&I,
952952
m_c_FMul(m_OneUse(m_Intrinsic<Intrinsic::tan>(m_Value(X))),
953-
m_OneUse(m_Intrinsic<Intrinsic::cos>(m_Specific(X)))))) {
953+
m_OneUse(m_Intrinsic<Intrinsic::cos>(m_Deferred(X)))))) {
954954
Value *Sin = Builder.CreateUnaryIntrinsic(Intrinsic::sin, X, &I);
955955
return replaceInstUsesWith(I, Sin);
956956
}

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ define double @fmul_strict_tan_strict_cos_reassoc(double %a) {
3232
define double @fmul_reassoc_tan_strict_cos_strict(double %a) {
3333
; CHECK-LABEL: define double @fmul_reassoc_tan_strict_cos_strict(
3434
; CHECK-SAME: double [[A:%.*]]) {
35-
; CHECK-NEXT: [[TAN:%.*]] = call double @llvm.tan.f64(double [[A]])
36-
; CHECK-NEXT: [[COS:%.*]] = call double @llvm.cos.f64(double [[A]])
37-
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[TAN]], [[COS]]
35+
; CHECK-NEXT: [[RES:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
3836
; CHECK-NEXT: ret double [[RES]]
3937
;
4038
%tan = call double @llvm.tan.f64(double %a)
@@ -46,9 +44,7 @@ define double @fmul_reassoc_tan_strict_cos_strict(double %a) {
4644
define double @fmul_reassoc_tan_reassoc_cos_strict(double %a) {
4745
; CHECK-LABEL: define double @fmul_reassoc_tan_reassoc_cos_strict(
4846
; CHECK-SAME: double [[A:%.*]]) {
49-
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @llvm.tan.f64(double [[A]])
50-
; CHECK-NEXT: [[COS:%.*]] = call double @llvm.cos.f64(double [[A]])
51-
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[TAN]], [[COS]]
47+
; CHECK-NEXT: [[RES:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
5248
; CHECK-NEXT: ret double [[RES]]
5349
;
5450
%tan = call reassoc double @llvm.tan.f64(double %a)
@@ -76,9 +72,7 @@ define double @fmul_tan_cos_reassoc_multiple_uses(double %a) {
7672
define double @fmul_tan_cos_reassoc(double %a) {
7773
; CHECK-LABEL: define double @fmul_tan_cos_reassoc(
7874
; CHECK-SAME: double [[A:%.*]]) {
79-
; CHECK-NEXT: [[TAN:%.*]] = call reassoc double @llvm.tan.f64(double [[A]])
80-
; CHECK-NEXT: [[COS:%.*]] = call reassoc double @llvm.cos.f64(double [[A]])
81-
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[TAN]], [[COS]]
75+
; CHECK-NEXT: [[RES:%.*]] = call reassoc double @llvm.sin.f64(double [[A]])
8276
; CHECK-NEXT: ret double [[RES]]
8377
;
8478
%tan = call reassoc double @llvm.tan.f64(double %a)
@@ -90,9 +84,7 @@ define double @fmul_tan_cos_reassoc(double %a) {
9084
define float @fmul_tanf_cosf_reassoc(float %a) {
9185
; CHECK-LABEL: define float @fmul_tanf_cosf_reassoc(
9286
; CHECK-SAME: float [[A:%.*]]) {
93-
; CHECK-NEXT: [[TAN:%.*]] = call reassoc float @llvm.tan.f32(float [[A]])
94-
; CHECK-NEXT: [[COS:%.*]] = call reassoc float @llvm.cos.f32(float [[A]])
95-
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc float [[TAN]], [[COS]]
87+
; CHECK-NEXT: [[RES:%.*]] = call reassoc float @llvm.sin.f32(float [[A]])
9688
; CHECK-NEXT: ret float [[RES]]
9789
;
9890
%tan = call reassoc float @llvm.tan.f32(float %a)
@@ -104,9 +96,7 @@ define float @fmul_tanf_cosf_reassoc(float %a) {
10496
define fp128 @fmul_tanfp128_cosfp128_reassoc(fp128 %a) {
10597
; CHECK-LABEL: define fp128 @fmul_tanfp128_cosfp128_reassoc(
10698
; CHECK-SAME: fp128 [[A:%.*]]) {
107-
; CHECK-NEXT: [[TAN:%.*]] = call reassoc fp128 @llvm.tan.f128(fp128 [[A]])
108-
; CHECK-NEXT: [[COS:%.*]] = call reassoc fp128 @llvm.cos.f128(fp128 [[A]])
109-
; CHECK-NEXT: [[RES:%.*]] = fmul reassoc fp128 [[TAN]], [[COS]]
99+
; CHECK-NEXT: [[RES:%.*]] = call reassoc fp128 @llvm.sin.f128(fp128 [[A]])
110100
; CHECK-NEXT: ret fp128 [[RES]]
111101
;
112102
%tan = call reassoc fp128 @llvm.tan.fp128(fp128 %a)

0 commit comments

Comments
 (0)