Skip to content

Commit 4f5355e

Browse files
committed
[PowerPC] Don't reuse an illegal typed load for int_to_fp conversion.
When the operand to an (s/u)int_to_fp node is an illegally typed load we cannot reuse the load address since we can not build a proper dependancy chain. The legalized loads will use a different chain output then the illegal load. If we reuse the load address then we will build a conversion node that uses the chain of the illegal load and operations which modify the memory address in the other dependancy chain can be scheduled before the floating point load which feeds the conversion. Differential Revision: https://reviews.llvm.org/D91265
1 parent 119545f commit 4f5355e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8413,6 +8413,13 @@ bool PPCTargetLowering::canReuseLoadAddress(SDValue Op, EVT MemVT,
84138413
if (LD->getMemoryVT() != MemVT)
84148414
return false;
84158415

8416+
// If the result of the load is an illegal type, then we can't build a
8417+
// valid chain for reuse since the legalised loads and token factor node that
8418+
// ties the legalised loads together uses a different output chain then the
8419+
// illegal load.
8420+
if (!isTypeLegal(LD->getValueType(0)))
8421+
return false;
8422+
84168423
RLI.Ptr = LD->getBasePtr();
84178424
if (LD->isIndexed() && !LD->getOffset().isUndef()) {
84188425
assert(LD->getAddressingMode() == ISD::PRE_INC &&
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc --verify-machineinstrs -mtriple powerpc-unknown-freebsd \
3+
; RUN: -mcpu=pwr4 < %s | FileCheck %s
4+
5+
define double @postinctodbl(i64* nocapture %llp) #0 {
6+
; CHECK-LABEL: postinctodbl:
7+
; CHECK: # %bb.0: # %entry
8+
; CHECK-NEXT: stwu 1, -16(1)
9+
; CHECK-NEXT: .cfi_def_cfa_offset 16
10+
; CHECK-NEXT: lwz 4, 4(3)
11+
; CHECK-NEXT: stw 4, 12(1)
12+
; CHECK-NEXT: addic 4, 4, 1
13+
; CHECK-NEXT: lwz 5, 0(3)
14+
; CHECK-NEXT: stw 5, 8(1)
15+
; CHECK-NEXT: addze 5, 5
16+
; CHECK-NEXT: lfd 0, 8(1)
17+
; CHECK-NEXT: stw 5, 0(3)
18+
; CHECK-NEXT: fcfid 1, 0
19+
; CHECK-NEXT: stw 4, 4(3)
20+
; CHECK-NEXT: addi 1, 1, 16
21+
; CHECK-NEXT: blr
22+
entry:
23+
%0 = load i64, i64* %llp, align 8
24+
%inc = add nsw i64 %0, 1
25+
store i64 %inc, i64* %llp, align 8
26+
%conv = sitofp i64 %0 to double
27+
ret double %conv
28+
}

0 commit comments

Comments
 (0)