-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[X86] Don't rely on global contraction flag #167252
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: main
Are you sure you want to change the base?
[X86] Don't rely on global contraction flag #167252
Conversation
|
@llvm/pr-subscribers-backend-x86 Author: Mikołaj Piróg (mikolaj-pirog) ChangesAs in title. See here for more context: https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract/80909 Testing has been updated in previous PRs, so no testing fail should be seen Full diff: https://github.com/llvm/llvm-project/pull/167252.diff 1 Files Affected:
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 05a854a0bf3fa..68dca58287c59 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -8434,7 +8434,6 @@ static bool isFMAddSubOrFMSubAdd(const X86Subtarget &Subtarget,
// or MUL + ADDSUB to FMADDSUB.
const TargetOptions &Options = DAG.getTarget().Options;
bool AllowFusion =
- Options.AllowFPOpFusion == FPOpFusion::Fast ||
(AllowSubAddOrAddSubContract && Opnd0->getFlags().hasAllowContract());
if (!AllowFusion)
return false;
@@ -54160,11 +54159,7 @@ static SDValue combineFMulcFCMulc(SDNode *N, SelectionDAG &DAG,
// FADD(A, FMA(B, C, 0)) and FADD(A, FMUL(B, C)) to FMA(B, C, A)
static SDValue combineFaddCFmul(SDNode *N, SelectionDAG &DAG,
const X86Subtarget &Subtarget) {
- auto AllowContract = [&DAG](const SDNodeFlags &Flags) {
- return DAG.getTarget().Options.AllowFPOpFusion == FPOpFusion::Fast ||
- Flags.hasAllowContract();
- };
-
+ bool AllowContract = N->getFlags().hasAllowContract();
auto HasNoSignedZero = [&DAG](const SDNodeFlags &Flags) {
return DAG.getTarget().Options.NoSignedZerosFPMath ||
Flags.hasNoSignedZeros();
@@ -54177,7 +54172,7 @@ static SDValue combineFaddCFmul(SDNode *N, SelectionDAG &DAG,
};
if (N->getOpcode() != ISD::FADD || !Subtarget.hasFP16() ||
- !AllowContract(N->getFlags()))
+ !AllowContract)
return SDValue();
EVT VT = N->getValueType(0);
@@ -54188,14 +54183,14 @@ static SDValue combineFaddCFmul(SDNode *N, SelectionDAG &DAG,
SDValue RHS = N->getOperand(1);
bool IsConj;
SDValue FAddOp1, MulOp0, MulOp1;
- auto GetCFmulFrom = [&MulOp0, &MulOp1, &IsConj, &AllowContract,
+ auto GetCFmulFrom = [&MulOp0, &MulOp1, &IsConj, AllowContract,
&IsVectorAllNegativeZero,
&HasNoSignedZero](SDValue N) -> bool {
if (!N.hasOneUse() || N.getOpcode() != ISD::BITCAST)
return false;
SDValue Op0 = N.getOperand(0);
unsigned Opcode = Op0.getOpcode();
- if (Op0.hasOneUse() && AllowContract(Op0->getFlags())) {
+ if (Op0.hasOneUse() && AllowContract) {
if ((Opcode == X86ISD::VFMULC || Opcode == X86ISD::VFCMULC)) {
MulOp0 = Op0.getOperand(0);
MulOp1 = Op0.getOperand(1);
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| SDValue Op0 = N.getOperand(0); | ||
| unsigned Opcode = Op0.getOpcode(); | ||
| if (Op0.hasOneUse() && AllowContract(Op0->getFlags())) { | ||
| if (Op0.hasOneUse() && AllowContract) { |
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.
Isn't it Op0->getFlags().hasAllowContract()?
|
Should we warn |
As in title. See here for more context: https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract/80909
Testing has been updated in previous PRs, so no testing fail should be seen