From: Qiu Chaofan Date: Wed, 16 Nov 2022 01:59:39 +0000 (+0800) Subject: [PowerPC] Fix strict load-conversion recognition X-Git-Tag: upstream/17.0.6~27537 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d19fea81fc2352100916e04e45adf5650b113f6;p=platform%2Fupstream%2Fllvm.git [PowerPC] Fix strict load-conversion recognition Direct-move instructions are usually more efficient than load then store for conversion. But direct moves are not needed when the source register was just loaded from some address. The pattern has already been recognized, but the source value of strict nodes are not the first (that's the chain), but the second. Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D138011 --- diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 2980047..3981c0c 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -8334,7 +8334,7 @@ void PPCTargetLowering::spliceIntoChain(SDValue ResChain, /// prefer float load to int load plus direct move /// when there is no integer use of int load bool PPCTargetLowering::directMoveIsProfitable(const SDValue &Op) const { - SDNode *Origin = Op.getOperand(0).getNode(); + SDNode *Origin = Op.getOperand(Op->isStrictFPOpcode() ? 1 : 0).getNode(); if (Origin->getOpcode() != ISD::LOAD) return true; diff --git a/llvm/test/CodeGen/PowerPC/fp-strict-conv.ll b/llvm/test/CodeGen/PowerPC/fp-strict-conv.ll index 6447520..600865e 100644 --- a/llvm/test/CodeGen/PowerPC/fp-strict-conv.ll +++ b/llvm/test/CodeGen/PowerPC/fp-strict-conv.ll @@ -501,8 +501,7 @@ entry: define double @load_i32_to_d(ptr %addr) #0 { ; CHECK-LABEL: load_i32_to_d: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: lwz r3, 0(r3) -; CHECK-NEXT: mtfprwa f0, r3 +; CHECK-NEXT: lfiwax f0, 0, r3 ; CHECK-NEXT: xscvsxddp f1, f0 ; CHECK-NEXT: blr ; @@ -520,8 +519,7 @@ entry: define double @load_i64_to_d(ptr %addr) #0 { ; CHECK-LABEL: load_i64_to_d: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: ld r3, 0(r3) -; CHECK-NEXT: mtfprd f0, r3 +; CHECK-NEXT: lfd f0, 0(r3) ; CHECK-NEXT: xscvsxddp f1, f0 ; CHECK-NEXT: blr ; @@ -539,8 +537,7 @@ entry: define double @load_u32_to_d(ptr %addr) #0 { ; CHECK-LABEL: load_u32_to_d: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: lwz r3, 0(r3) -; CHECK-NEXT: mtfprwz f0, r3 +; CHECK-NEXT: lfiwzx f0, 0, r3 ; CHECK-NEXT: xscvuxddp f1, f0 ; CHECK-NEXT: blr ; @@ -558,8 +555,7 @@ entry: define double @load_u64_to_d(ptr %addr) #0 { ; CHECK-LABEL: load_u64_to_d: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: ld r3, 0(r3) -; CHECK-NEXT: mtfprd f0, r3 +; CHECK-NEXT: lfd f0, 0(r3) ; CHECK-NEXT: xscvuxddp f1, f0 ; CHECK-NEXT: blr ; @@ -577,8 +573,7 @@ entry: define float @load_i32_to_f(ptr %addr) #0 { ; CHECK-LABEL: load_i32_to_f: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: lwz r3, 0(r3) -; CHECK-NEXT: mtfprwa f0, r3 +; CHECK-NEXT: lfiwax f0, 0, r3 ; CHECK-NEXT: xscvsxdsp f1, f0 ; CHECK-NEXT: blr ; @@ -596,8 +591,7 @@ entry: define float @load_i64_to_f(ptr %addr) #0 { ; CHECK-LABEL: load_i64_to_f: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: ld r3, 0(r3) -; CHECK-NEXT: mtfprd f0, r3 +; CHECK-NEXT: lfd f0, 0(r3) ; CHECK-NEXT: xscvsxdsp f1, f0 ; CHECK-NEXT: blr ; @@ -615,8 +609,7 @@ entry: define float @load_u32_to_f(ptr %addr) #0 { ; CHECK-LABEL: load_u32_to_f: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: lwz r3, 0(r3) -; CHECK-NEXT: mtfprwz f0, r3 +; CHECK-NEXT: lfiwzx f0, 0, r3 ; CHECK-NEXT: xscvuxdsp f1, f0 ; CHECK-NEXT: blr ; @@ -634,8 +627,7 @@ entry: define float @load_u64_to_f(ptr %addr) #0 { ; CHECK-LABEL: load_u64_to_f: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT: ld r3, 0(r3) -; CHECK-NEXT: mtfprd f0, r3 +; CHECK-NEXT: lfd f0, 0(r3) ; CHECK-NEXT: xscvuxdsp f1, f0 ; CHECK-NEXT: blr ;