Skip to content

Commit 79b50e9

Browse files
committed
[SDAG] Only apply sincos stack slot folding to IR pointers
Fixes #115323
1 parent 3ad0148 commit 79b50e9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,6 +2519,7 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
25192519
unsigned ResNo = StoreValue.getResNo();
25202520
Type *StoreType = StoreValue.getValueType().getTypeForEVT(Ctx);
25212521
if (CallRetResNo == ResNo || !ST->isSimple() ||
2522+
!isa<const Value *>(ST->getPointerInfo().V) ||
25222523
ST->getAddressSpace() != 0 ||
25232524
ST->getAlign() <
25242525
getDataLayout().getABITypeAlign(StoreType->getScalarType()) ||
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no_x86_scrub_sp --version 5
2+
; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s
3+
; Test for issue https://github.com/llvm/llvm-project/issues/115323
4+
5+
declare double @g(double, double)
6+
7+
define double @f(double %a) {
8+
; CHECK-LABEL: f:
9+
; CHECK: # %bb.0: # %entry
10+
; CHECK-NEXT: subl $44, %esp
11+
; CHECK-NEXT: .cfi_def_cfa_offset 48
12+
; CHECK-NEXT: fldl 48(%esp)
13+
; CHECK-NEXT: leal 24(%esp), %eax
14+
; CHECK-NEXT: movl %eax, 12(%esp)
15+
; CHECK-NEXT: leal 32(%esp), %eax
16+
; CHECK-NEXT: movl %eax, 8(%esp)
17+
; CHECK-NEXT: fstpl (%esp)
18+
; CHECK-NEXT: calll sincos
19+
; CHECK-NEXT: fldl 32(%esp)
20+
; CHECK-NEXT: fldl 24(%esp)
21+
; CHECK-NEXT: faddl {{\.?LCPI[0-9]+_[0-9]+}}
22+
; CHECK-NEXT: fxch %st(1)
23+
; CHECK-NEXT: fstpl 8(%esp)
24+
; CHECK-NEXT: fstpl (%esp)
25+
; CHECK-NEXT: calll g@PLT
26+
; CHECK-NEXT: addl $44, %esp
27+
; CHECK-NEXT: .cfi_def_cfa_offset 4
28+
; CHECK-NEXT: retl
29+
entry:
30+
%0 = tail call double @llvm.sin.f64(double %a)
31+
%1 = tail call double @llvm.cos.f64(double %a)
32+
%add = fadd double %1, 3.140000e+00
33+
%call = tail call double @g(double %add, double %0)
34+
ret double %call
35+
}

0 commit comments

Comments
 (0)