[PATCH] D98791: [PowerPC][NFC] Do not enter prefix selection if it cannot do better.

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 09:40:09 PDT 2021


stefanp created this revision.
stefanp added a reviewer: nemanjai.
Herald added subscribers: shchenz, kbarton, hiraditya.
stefanp requested review of this revision.
Herald added a project: LLVM.

Do not try to materialize a constant using prefix instructions if the selection
using non prefix instructions was able to do it using a single non prefix
instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98791

Files:
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp


Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1167,7 +1167,11 @@
   const PPCSubtarget &Subtarget =
       CurDAG->getMachineFunction().getSubtarget<PPCSubtarget>();
 
-  if (Subtarget.hasPrefixInstrs()) {
+  // If we have prefix instructions and the non prefix selection decided that
+  // it cannot materialize the constant in a single instruction it is worth
+  // trying to materialize using perfix instructions. If the non prefix
+  // selection used one instruction we cannot do better.
+  if (Subtarget.hasPrefixInstrs() && InstCntDirect != 1) {
     unsigned InstCntDirectP = 0;
     SDNode *ResultP = selectI64ImmDirectPrefix(CurDAG, dl, Imm, InstCntDirectP);
     // Use the prefix case in either of two cases:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98791.331294.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/2a5f2e09/attachment.bin>


More information about the llvm-commits mailing list