[PATCH] D91845: [PowerPC] Fix FLT_ROUNDS_ on little endian
Qiu Chaofan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 00:02:19 PST 2020
qiucf updated this revision to Diff 308888.
qiucf marked 2 inline comments as done.
qiucf added a comment.
Address comments
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91845/new/
https://reviews.llvm.org/D91845
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/frounds.ll
Index: llvm/test/CodeGen/PowerPC/frounds.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/frounds.ll
+++ llvm/test/CodeGen/PowerPC/frounds.ll
@@ -42,7 +42,7 @@
; PPC64LE: # %bb.0: # %entry
; PPC64LE-NEXT: mffs 0
; PPC64LE-NEXT: stfd 0, -16(1)
-; PPC64LE-NEXT: lwz 3, -12(1)
+; PPC64LE-NEXT: lwz 3, -16(1)
; PPC64LE-NEXT: not 4, 3
; PPC64LE-NEXT: clrlwi 3, 3, 30
; PPC64LE-NEXT: rlwinm 4, 4, 31, 31, 31
@@ -54,8 +54,7 @@
; DM-LABEL: foo:
; DM: # %bb.0: # %entry
; DM-NEXT: mffs 0
-; DM-NEXT: stfd 0, -16(1)
-; DM-NEXT: lwz 3, -12(1)
+; DM-NEXT: mffprd 3, 0
; DM-NEXT: not 4, 3
; DM-NEXT: clrlwi 3, 3, 30
; DM-NEXT: rlwinm 4, 4, 31, 31, 31
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8961,16 +8961,24 @@
SDValue MFFS = DAG.getNode(PPCISD::MFFS, dl, {MVT::f64, MVT::Other}, Chain);
Chain = MFFS.getValue(1);
- // Save FP register to stack slot
- int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
- SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
- Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo());
-
- // Load FP Control Word from low 32 bits of stack slot.
- SDValue Four = DAG.getConstant(4, dl, PtrVT);
- SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four);
- SDValue CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo());
- Chain = CWD.getValue(1);
+ SDValue CWD;
+ if (isTypeLegal(MVT::i64)) {
+ CWD = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32,
+ DAG.getNode(ISD::BITCAST, dl, MVT::i64, MFFS));
+ } else {
+ // Save FP register to stack slot
+ int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
+ SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
+ Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo());
+
+ // Load FP Control Word from low 32 bits of stack slot.
+ assert(hasBigEndianPartOrdering(MVT::i64, MF.getDataLayout()) &&
+ "Stack slot adjustment is valid only on big endian subtargets!");
+ SDValue Four = DAG.getConstant(4, dl, PtrVT);
+ SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four);
+ CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo());
+ Chain = CWD.getValue(1);
+ }
// Transform as necessary
SDValue CWD1 =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91845.308888.patch
Type: text/x-patch
Size: 2549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201202/e22bb07a/attachment.bin>
More information about the llvm-commits
mailing list