Power ISA 3.1 adds xsmaxcqp/xsmincqp for quad-precision type-c max/min selection, and this opens the opportunity to improve instruction selection on: llvm.maxnum.f128, llvm.minnum.f128, and select_cc ordered gt/lt and (don't care) gt/lt.
Details
- Reviewers
nemanjai jsji shchenz amyk - Group Reviewers
Restricted Project - Commits
- rG097a95f2df46: [PowerPC] Add custom lowering for SELECT_CC fp128 using xsmaxcqp
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
1345 | We already have a setOperationAction(ISD::SELECT_CC, MVT::f128, Custom); under Subtarget.hasVSX(), so don't need this. | |
8028 | We don't need to add new ISD node, but XS(MAX|MIN)CDP node need renaming. | |
llvm/lib/Target/PowerPC/PPCInstrInfo.td | ||
223 | Operator PPCxsmaxc is type agnostic, we don't need to define PPCxsmaxcq. | |
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
1915–1918 | I'm not sure why xscmpeqqp are located here, but this should be better placed at PPCInstrVSX.td. | |
llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll | ||
2 | Why not add them into scalar-min-max.ll (with a new -mcpu=pwr10 runline)? |
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
1345 | That setOperationAction is located under the else part of Subtarget.hasP9Vector(), since P9Vector is part of P9InheritableFeatures, P10 test Subtarget.hasP9Vector() as true, so not hit that setOperationAction. Since this is supported by P10, and do not see Subtarget.hasP10Vector() predicate in this file, so added one under the Subtarget.hasAltivec() big block. | |
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
1915–1918 | Thanks! I will move XS(MAX|MIN)CQP to sit together with XSMAXCDP. | |
llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll | ||
2 | That test checks pwr8 behavior, which I don't like to do for fp128, and that's why added a separate file. |
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
---|---|---|
1915–1918 | A closer look at PPCInstrPrefix.td and PPCInstrVSX.td, all instructions with Power10Instrs predicate are located inside PPCInstrPrefix.td, and does not have any in PPCInstrVSX.td. There maybe some other preference regarding the placement, guess just leave it as is... |
Renamed PPCISD::XS[MAX|MIN]CDP to PPCISD::XS[MAX|MIN]C, and use the nodes for both dual-precision and quad-precision type-c instructions
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
---|---|---|
1915–1918 | The name 'Prefix' stands for new ISA 3.1 feature - prefixed instruction, but 128-bit fp max/min is not one of them. Anyway, it's okay to leave them here and we'll do clean-up in the future when all Power10 instructions are implemented. |
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
1345 | What if we set Custom for SELECT_CC for all targets hasVSX()? I don't see a reason why we can not set setOperationAction(ISD::SELECT_CC, MVT::f128, Custom); on Power9. If so, we can just set SELECT_CC for type f128 under hasVSX() instead of setting it two times for P10 and hasVSX()? |
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
1345 | Had a try doing Custom on Power9 to SELECT_CC, that path caused dump. Following is the path taken by fp128/Power9/SELECT_CC, and picks up PPC::XSCMPUQP: Seems the expected code paths for Power9 and Power10 are different, then we still need a predicate to differentiate that? |
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | ||
---|---|---|
1345 | OK, thanks for the explanation. I think it crashes because we don't handle PPCISD::XSMAXC and PPCISD::XSMINC for type f128 on Power9 in the legalizer. However, I really think the logic for select_cc is kind of confusing on Power, we legalize it(set operation as custom) for Power8 and Power10, and we set it legal on Power9 and then do the selecting just before we select from td files. Maybe we can do some code refactor here later to make the logic be more clear. This should be out of this PR. | |
llvm/test/CodeGen/PowerPC/scalar-min-max-p10.ll | ||
1 | Better to generate check lines by using scripts like ./utils/update_llc_test_checks.py. And could you please also add a RUN line for AIX? |
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
---|---|---|
1915–1918 | Please do not move any instructions out of this file piecemeal at this time. The name of this file is temporary as we kept all the Power10 instructions in one file during the incremental development process prior to the announcement of Power10. We need to decide where we want the various groups of instructions to live and move them and/or rename files accordingly. This will be done all at once to make it obvious in the repo history when this happened and what was happening. |
(1) Add llvm.maxnum/minnum.f128 check case for P10
(2) Update test case using the script: update_llc_test_checks.py
Overall LGTM.
llvm/lib/Target/PowerPC/PPCInstrPrefix.td | ||
---|---|---|
1915–1918 | These are meant to be put under [IsISA3_1, HasVSX], right? |
We already have a setOperationAction(ISD::SELECT_CC, MVT::f128, Custom); under Subtarget.hasVSX(), so don't need this.