Skip to content

Commit fea5554

Browse files
committed
SimplifyLibCalls: Skip sincospi optimization for ConstantData
Avoids looking at the uselist, and it would probably be more productive to constant fold this.
1 parent 981f435 commit fea5554

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -3002,6 +3002,9 @@ Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBa
30023002
return nullptr;
30033003

30043004
Value *Arg = CI->getArgOperand(0);
3005+
if (isa<ConstantData>(Arg))
3006+
return nullptr;
3007+
30053008
SmallVector<CallInst *, 1> SinCalls;
30063009
SmallVector<CallInst *, 1> CosCalls;
30073010
SmallVector<CallInst *, 1> SinCosCalls;

llvm/test/Transforms/InstCombine/sincospi.ll

+8-16
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,14 @@ define float @test_instbased_f32_other_user(ptr %ptr) {
9090

9191
define float @test_constant_f32() {
9292
; CHECK-FLOAT-IN-VEC-LABEL: @test_constant_f32(
93-
; CHECK-FLOAT-IN-VEC-NEXT: [[SINCOSPI:%.*]] = call <2 x float> @__sincospif_stret(float 1.000000e+00)
94-
; CHECK-FLOAT-IN-VEC-NEXT: [[SINPI:%.*]] = extractelement <2 x float> [[SINCOSPI]], i64 0
95-
; CHECK-FLOAT-IN-VEC-NEXT: [[COSPI:%.*]] = extractelement <2 x float> [[SINCOSPI]], i64 1
96-
; CHECK-FLOAT-IN-VEC-NEXT: [[COS:%.*]] = call float @__cospif(float 1.000000e+00) #[[ATTR0]]
93+
; CHECK-FLOAT-IN-VEC-NEXT: [[SINPI:%.*]] = call float @__sinpif(float 1.000000e+00) #[[ATTR0]]
94+
; CHECK-FLOAT-IN-VEC-NEXT: [[COSPI:%.*]] = call float @__cospif(float 1.000000e+00) #[[ATTR0]]
9795
; CHECK-FLOAT-IN-VEC-NEXT: [[RES:%.*]] = fadd float [[SINPI]], [[COSPI]]
9896
; CHECK-FLOAT-IN-VEC-NEXT: ret float [[RES]]
9997
;
10098
; CHECK-LABEL: @test_constant_f32(
101-
; CHECK-NEXT: [[SINCOSPI:%.*]] = call { float, float } @__sincospif_stret(float 1.000000e+00)
102-
; CHECK-NEXT: [[SINPI:%.*]] = extractvalue { float, float } [[SINCOSPI]], 0
103-
; CHECK-NEXT: [[COSPI:%.*]] = extractvalue { float, float } [[SINCOSPI]], 1
104-
; CHECK-NEXT: [[COS:%.*]] = call float @__cospif(float 1.000000e+00) #[[ATTR0]]
99+
; CHECK-NEXT: [[SINPI:%.*]] = call float @__sinpif(float 1.000000e+00) #[[ATTR0]]
100+
; CHECK-NEXT: [[COSPI:%.*]] = call float @__cospif(float 1.000000e+00) #[[ATTR0]]
105101
; CHECK-NEXT: [[RES:%.*]] = fadd float [[SINPI]], [[COSPI]]
106102
; CHECK-NEXT: ret float [[RES]]
107103
;
@@ -172,18 +168,14 @@ define double @test_instbased_f64() {
172168

173169
define double @test_constant_f64() {
174170
; CHECK-FLOAT-IN-VEC-LABEL: @test_constant_f64(
175-
; CHECK-FLOAT-IN-VEC-NEXT: [[SINCOSPI:%.*]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
176-
; CHECK-FLOAT-IN-VEC-NEXT: [[SINPI:%.*]] = extractvalue { double, double } [[SINCOSPI]], 0
177-
; CHECK-FLOAT-IN-VEC-NEXT: [[COSPI:%.*]] = extractvalue { double, double } [[SINCOSPI]], 1
178-
; CHECK-FLOAT-IN-VEC-NEXT: [[COS:%.*]] = call double @__cospi(double 1.000000e+00) #[[ATTR0]]
171+
; CHECK-FLOAT-IN-VEC-NEXT: [[SINPI:%.*]] = call double @__sinpi(double 1.000000e+00) #[[ATTR0]]
172+
; CHECK-FLOAT-IN-VEC-NEXT: [[COSPI:%.*]] = call double @__cospi(double 1.000000e+00) #[[ATTR0]]
179173
; CHECK-FLOAT-IN-VEC-NEXT: [[RES:%.*]] = fadd double [[SINPI]], [[COSPI]]
180174
; CHECK-FLOAT-IN-VEC-NEXT: ret double [[RES]]
181175
;
182176
; CHECK-LABEL: @test_constant_f64(
183-
; CHECK-NEXT: [[SINCOSPI:%.*]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
184-
; CHECK-NEXT: [[SINPI:%.*]] = extractvalue { double, double } [[SINCOSPI]], 0
185-
; CHECK-NEXT: [[COSPI:%.*]] = extractvalue { double, double } [[SINCOSPI]], 1
186-
; CHECK-NEXT: [[COS:%.*]] = call double @__cospi(double 1.000000e+00) #[[ATTR0]]
177+
; CHECK-NEXT: [[SINPI:%.*]] = call double @__sinpi(double 1.000000e+00) #[[ATTR0]]
178+
; CHECK-NEXT: [[COSPI:%.*]] = call double @__cospi(double 1.000000e+00) #[[ATTR0]]
187179
; CHECK-NEXT: [[RES:%.*]] = fadd double [[SINPI]], [[COSPI]]
188180
; CHECK-NEXT: ret double [[RES]]
189181
;

0 commit comments

Comments
 (0)