Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18673,11 +18673,13 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) {
if (Flags.hasAllowReciprocal()) {
// If this FDIV is part of a reciprocal square root, it may be folded
// into a target-specific square root estimate instruction.
bool N1AllowReciprocal = N1->getFlags().hasAllowReciprocal();
if (N1.getOpcode() == ISD::FSQRT) {
if (SDValue RV = buildRsqrtEstimate(N1.getOperand(0)))
return DAG.getNode(ISD::FMUL, DL, VT, N0, RV);
} else if (N1.getOpcode() == ISD::FP_EXTEND &&
N1.getOperand(0).getOpcode() == ISD::FSQRT) {
N1.getOperand(0).getOpcode() == ISD::FSQRT &&
N1AllowReciprocal) {
if (SDValue RV = buildRsqrtEstimate(N1.getOperand(0).getOperand(0))) {
RV = DAG.getNode(ISD::FP_EXTEND, SDLoc(N1), VT, RV);
AddToWorklist(RV.getNode());
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3976,7 +3976,10 @@ void SelectionDAGBuilder::visitFPExt(const User &I) {
SDValue N = getValue(I.getOperand(0));
EVT DestVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
I.getType());
setValue(&I, DAG.getNode(ISD::FP_EXTEND, getCurSDLoc(), DestVT, N));
SDNodeFlags Flags;
if (auto *TruncInst = dyn_cast<FPMathOperator>(&I))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TruncInst is confusing here (I guess it has been copied from somewhere). You could perhaps all it Operator or FPExtInst or something, but it seems like FPOp is a common variable name when dyn_cast-ing to a FPMathOperator. So I would suggest FPOp.

Flags.copyFMF(*TruncInst);
setValue(&I, DAG.getNode(ISD::FP_EXTEND, getCurSDLoc(), DestVT, N, Flags));
}

void SelectionDAGBuilder::visitFPToUI(const User &I) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/PowerPC/recipest.ll
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ define double @foof_fmf(double %a, float %b) nounwind {
; CHECK-P9-NEXT: xsmuldp f1, f1, f0
; CHECK-P9-NEXT: blr
%x = call contract reassoc arcp float @llvm.sqrt.f32(float %b)
%y = fpext float %x to double
%y = fpext arcp float %x to double
%r = fdiv contract reassoc arcp double %a, %y
ret double %r
}
Expand Down
Loading