-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[SelectionDAG] Adaptation for FP operation lowering #138553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/spavloff/fadd
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6802,9 +6802,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, | |
case Intrinsic::exp10: | ||
case Intrinsic::floor: | ||
case Intrinsic::ceil: | ||
case Intrinsic::trunc: | ||
case Intrinsic::rint: | ||
case Intrinsic::nearbyint: | ||
case Intrinsic::round: | ||
case Intrinsic::roundeven: | ||
case Intrinsic::canonicalize: { | ||
|
@@ -6826,9 +6824,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, | |
case Intrinsic::exp10: Opcode = ISD::FEXP10; break; | ||
case Intrinsic::floor: Opcode = ISD::FFLOOR; break; | ||
case Intrinsic::ceil: Opcode = ISD::FCEIL; break; | ||
case Intrinsic::trunc: Opcode = ISD::FTRUNC; break; | ||
case Intrinsic::rint: Opcode = ISD::FRINT; break; | ||
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break; | ||
case Intrinsic::round: Opcode = ISD::FROUND; break; | ||
case Intrinsic::roundeven: Opcode = ISD::FROUNDEVEN; break; | ||
case Intrinsic::canonicalize: Opcode = ISD::FCANONICALIZE; break; | ||
|
@@ -6959,6 +6955,11 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, | |
#include "llvm/IR/ConstrainedOps.def" | ||
visitConstrainedFPIntrinsic(cast<ConstrainedFPIntrinsic>(I)); | ||
return; | ||
#define CONSTRAINED(INTRINSIC, DAGN) | ||
#define FUNCTION(INTRINSIC, DAGN) case Intrinsic::INTRINSIC: | ||
#include "llvm/IR/FloatingPointOps.def" | ||
visitFPOperationIntrinsic(I, Intrinsic); | ||
return; | ||
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID: | ||
#include "llvm/IR/VPIntrinsics.def" | ||
visitVectorPredicationIntrinsic(cast<VPIntrinsic>(I)); | ||
|
@@ -8350,6 +8351,59 @@ void SelectionDAGBuilder::visitConstrainedFPIntrinsic( | |
setValue(&FPI, FPResult); | ||
} | ||
|
||
void SelectionDAGBuilder::visitFPOperationIntrinsic(const CallInst &CI, | ||
unsigned Intrinsic) { | ||
SDLoc sdl = getCurSDLoc(); | ||
bool StrictFP = | ||
FuncInfo.Fn->getAttributes().hasFnAttr(llvm::Attribute::StrictFP); | ||
|
||
int Opcode = -1; | ||
switch (Intrinsic) { | ||
#define CONSTRAINED(NAME, DAGN) | ||
#define FUNCTION(NAME, DAGN) \ | ||
case Intrinsic::NAME: \ | ||
Opcode = StrictFP ? ISD::STRICT_##DAGN : ISD::DAGN; \ | ||
break; | ||
#include "llvm/IR/FloatingPointOps.def" | ||
} | ||
|
||
SDNodeFlags Flags; | ||
if (CI.getExceptionBehavior() == fp::ExceptionBehavior::ebIgnore) | ||
Flags.setNoFPExcept(true); | ||
Comment on lines
+8371
to
+8372
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you reorder this with the use of CI.getExceptionBehavior below, so all of the exception mode dependent code is together There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code was copied from |
||
if (auto *FPOp = dyn_cast<FPMathOperator>(&CI)) | ||
Flags.copyFMF(*FPOp); | ||
|
||
SmallVector<SDValue, 4> Operands; | ||
if (StrictFP) | ||
Operands.push_back(DAG.getRoot()); | ||
for (unsigned I = 0, E = CI.arg_size(); I != E; ++I) | ||
Operands.push_back(getValue(CI.getArgOperand(I))); | ||
|
||
const TargetLowering &TLI = DAG.getTargetLoweringInfo(); | ||
EVT VT = TLI.getValueType(DAG.getDataLayout(), CI.getType()); | ||
SDVTList VTs = StrictFP ? DAG.getVTList(VT, MVT::Other) : DAG.getVTList(VT); | ||
|
||
SDValue Result = DAG.getNode(Opcode, sdl, VTs, Operands, Flags); | ||
|
||
SDValue OutChain; | ||
if (StrictFP) { | ||
OutChain = Result.getValue(1); | ||
switch (CI.getExceptionBehavior()) { | ||
case fp::ExceptionBehavior::ebIgnore: | ||
case fp::ExceptionBehavior::ebMayTrap: | ||
PendingConstrainedFP.push_back(OutChain); | ||
break; | ||
case fp::ExceptionBehavior::ebStrict: | ||
PendingConstrainedFPStrict.push_back(OutChain); | ||
break; | ||
} | ||
SDValue FPResult = Result.getValue(0); | ||
setValue(&CI, FPResult); | ||
} else { | ||
setValue(&CI, Result); | ||
} | ||
} | ||
|
||
static unsigned getISDForVPIntrinsic(const VPIntrinsic &VPIntrin) { | ||
std::optional<unsigned> ResOPC; | ||
switch (VPIntrin.getIntrinsicID()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these two not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are handles together with all floating-point operations, see the code added at line 6958.