[llvm] b8f3c6d - [PowerPC][NFC] Do not enter prefix selection if it cannot do better.

Stefan Pintilie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 07:18:26 PDT 2021


Author: Stefan Pintilie
Date: 2021-03-22T09:17:52-05:00
New Revision: b8f3c6d0110f60bcdd9af7fa2c97ee0a21b05d25

URL: https://github.com/llvm/llvm-project/commit/b8f3c6d0110f60bcdd9af7fa2c97ee0a21b05d25
DIFF: https://github.com/llvm/llvm-project/commit/b8f3c6d0110f60bcdd9af7fa2c97ee0a21b05d25.diff

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

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.

Reviewed By: nemanjai, #powerpc

Differential Revision: https://reviews.llvm.org/D98791

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index 0f6212621ac2..dd7b7a345d66 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1167,7 +1167,10 @@ static SDNode *selectI64Imm(SelectionDAG *CurDAG, const SDLoc &dl, uint64_t Imm,
   const PPCSubtarget &Subtarget =
       CurDAG->getMachineFunction().getSubtarget<PPCSubtarget>();
 
-  if (Subtarget.hasPrefixInstrs()) {
+  // If we have prefixed instructions and there is a chance we can
+  // materialize the constant with fewer prefixed instructions than
+  // non-prefixed, try that.
+  if (Subtarget.hasPrefixInstrs() && InstCntDirect != 1) {
     unsigned InstCntDirectP = 0;
     SDNode *ResultP = selectI64ImmDirectPrefix(CurDAG, dl, Imm, InstCntDirectP);
     // Use the prefix case in either of two cases:


        


More information about the llvm-commits mailing list