[PATCH] D34986: [PowerPC] avoid redundant analysis while lowering an immediate; NFC

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 08:25:50 PDT 2017


inouehrs created this revision.

This patch reduces compilation time by avoiding redundant analysis while selecting instructions to create an immediate.
If the instruction count required to create the input number without rotate is 2, we do not need further analysis to find a shorter instruction sequence with rotate; rotate + load constant cannot be done by 1 instruction (i.e. `getInt64CountDirect`never return 0).
This patch should not change functionality.


https://reviews.llvm.org/D34986

Files:
  lib/Target/PowerPC/PPCISelDAGToDAG.cpp


Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -728,7 +728,7 @@
 
 static unsigned getInt64Count(int64_t Imm) {
   unsigned Count = getInt64CountDirect(Imm);
-  if (Count == 1)
+  if (Count <= 2)
     return Count;
 
   for (unsigned r = 1; r < 63; ++r) {
@@ -838,7 +838,7 @@
 
 static SDNode *getInt64(SelectionDAG *CurDAG, const SDLoc &dl, int64_t Imm) {
   unsigned Count = getInt64CountDirect(Imm);
-  if (Count == 1)
+  if (Count <= 2)
     return getInt64Direct(CurDAG, dl, Imm);
 
   unsigned RMin = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34986.105178.patch
Type: text/x-patch
Size: 666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170704/477a7dff/attachment-0001.bin>


More information about the llvm-commits mailing list