Skip to content

PPC: Custom lower ppcf128 is_fpclass if is_fpclass is custom #105540

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

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Aug 21, 2024

Unfortunately expandIS_FPCLASS is called directly in SelectionDAGBuilder
depending on whether IS_FPCLASS is custom or not. This helps avoid ppc test
regressions in a future patch where the custom lowering would be bypassed.

Copy link
Contributor Author

arsenm commented Aug 21, 2024

@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2024

@llvm/pr-subscribers-backend-powerpc

Author: Matt Arsenault (arsenm)

Changes

Unfortunately expandIS_FPCLASS is called directly in SelectionDAGBuilder
depending on whether IS_FPCLASS is custom or not. This helps avoid ppc test
regressions in a future patch where the custom lowering would be bypassed.


Full diff: https://github.com/llvm/llvm-project/pull/105540.diff

1 Files Affected:

  • (modified) llvm/lib/Target/PowerPC/PPCISelLowering.cpp (+7)
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 459a96eca1ff20..a5bc24b55660a5 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1221,6 +1221,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
         setOperationAction(ISD::IS_FPCLASS, MVT::f32, Custom);
         setOperationAction(ISD::IS_FPCLASS, MVT::f64, Custom);
         setOperationAction(ISD::IS_FPCLASS, MVT::f128, Custom);
+        setOperationAction(ISD::IS_FPCLASS, MVT::ppcf128, Custom);
       }
 
       // 128 bit shifts can be accomplished via 3 instructions for SHL and
@@ -11479,6 +11480,12 @@ SDValue PPCTargetLowering::LowerIS_FPCLASS(SDValue Op,
   uint64_t RHSC = Op.getConstantOperandVal(1);
   SDLoc Dl(Op);
   FPClassTest Category = static_cast<FPClassTest>(RHSC);
+  if (LHS.getValueType() == MVT::ppcf128) {
+    // The higher part determines the value class.
+    LHS = DAG.getNode(ISD::EXTRACT_ELEMENT, Dl, MVT::f64, LHS,
+                      DAG.getConstant(1, Dl, MVT::i32));
+  }
+
   return getDataClassTest(LHS, Category, Dl, DAG, Subtarget);
 }
 

@@ -11479,6 +11480,12 @@ SDValue PPCTargetLowering::LowerIS_FPCLASS(SDValue Op,
uint64_t RHSC = Op.getConstantOperandVal(1);
SDLoc Dl(Op);
FPClassTest Category = static_cast<FPClassTest>(RHSC);
if (LHS.getValueType() == MVT::ppcf128) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this code:

// PPC double double is a pair of doubles, of which the higher part determines
// the value class.
if (OperandVT == MVT::ppcf128) {
Op = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::f64, Op,
DAG.getConstant(1, DL, MVT::i32));
OperandVT = MVT::f64;
}
is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still needed. PPC only custom lowers this for Subtarget.useCRBits, otherwise it still hits the default expansion

@arsenm arsenm force-pushed the users/arsenm/ppcf128-custom-lower branch from 99b4eb6 to 5c5122c Compare August 29, 2024 04:18
@spavloff
Copy link
Collaborator

LGTM.

Copy link
Contributor Author

arsenm commented Aug 29, 2024

Merge activity

  • Aug 29, 5:54 AM EDT: @arsenm started a stack merge that includes this pull request via Graphite.
  • Aug 29, 5:56 AM EDT: Graphite rebased this pull request as part of a merge.
  • Aug 29, 5:59 AM EDT: Graphite rebased this pull request as part of a merge.
  • Aug 29, 6:01 AM EDT: @arsenm merged this pull request with Graphite.

@arsenm arsenm force-pushed the users/arsenm/ppcf128-custom-lower branch from 5c5122c to 151d8a4 Compare August 29, 2024 09:55
Unfortunately expandIS_FPCLASS is called directly in SelectionDAGBuilder
depending on whether IS_FPCLASS is custom or not. This helps avoid ppc test
regressions in a future patch where the custom lowering would be bypassed.
@arsenm arsenm force-pushed the users/arsenm/ppcf128-custom-lower branch from 151d8a4 to 4db76dc Compare August 29, 2024 09:59
@arsenm arsenm merged commit 911b960 into main Aug 29, 2024
5 of 6 checks passed
@arsenm arsenm deleted the users/arsenm/ppcf128-custom-lower branch August 29, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants