Skip to content

Commit be65788

Browse files
committed
[SDAG] Fix llvm.modf for ppc_fp128 (attempt two)
Apparently `DAG.getRoot()` can return null, so we need to check that case. Hopefully fixes: https://lab.llvm.org/buildbot/#/builders/72/builds/8406
1 parent 2c022e3 commit be65788

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,8 +2644,10 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
26442644
// optimized out. This prevents an FP stack pop from being emitted for it.
26452645
// Setting the root like this ensures there will be a use of the
26462646
// `CopyFromReg` chain, and ensures the FP pop will be emitted.
2647+
SDValue OldRoot = getRoot();
26472648
SDValue NewRoot =
2648-
getNode(ISD::TokenFactor, DL, MVT::Other, getRoot(), CallChain);
2649+
OldRoot ? getNode(ISD::TokenFactor, DL, MVT::Other, OldRoot, CallChain)
2650+
: CallChain;
26492651
setRoot(NewRoot);
26502652
// Ensure the new root is reachable from the results.
26512653
Results[0] = getMergeValues({Results[0], NewRoot}, DL);

llvm/test/CodeGen/PowerPC/llvm.modf.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,25 @@ define { ppc_fp128, ppc_fp128 } @test_modf_ppcf128(ppc_fp128 %a) {
328328
%result = call { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %a)
329329
ret { ppc_fp128, ppc_fp128 } %result
330330
}
331+
332+
define ppc_fp128 @test_modf_ppcf128_only_use_intergral(ppc_fp128 %a) {
333+
; CHECK-LABEL: test_modf_ppcf128_only_use_intergral:
334+
; CHECK: # %bb.0:
335+
; CHECK-NEXT: mflr r0
336+
; CHECK-NEXT: stdu r1, -48(r1)
337+
; CHECK-NEXT: std r0, 64(r1)
338+
; CHECK-NEXT: .cfi_def_cfa_offset 48
339+
; CHECK-NEXT: .cfi_offset lr, 16
340+
; CHECK-NEXT: addi r5, r1, 32
341+
; CHECK-NEXT: bl modfl
342+
; CHECK-NEXT: nop
343+
; CHECK-NEXT: lfd f1, 32(r1)
344+
; CHECK-NEXT: lfd f2, 40(r1)
345+
; CHECK-NEXT: addi r1, r1, 48
346+
; CHECK-NEXT: ld r0, 16(r1)
347+
; CHECK-NEXT: mtlr r0
348+
; CHECK-NEXT: blr
349+
%result = call { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %a)
350+
%result.1 = extractvalue { ppc_fp128, ppc_fp128 } %result, 1
351+
ret ppc_fp128 %result.1
352+
}

0 commit comments

Comments
 (0)