[PATCH] D58461: [AArch64] Small fix for getIntImmCost

Adhemerval Zanella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 11:45:25 PST 2019


zatrazz updated this revision to Diff 189177.
zatrazz edited the summary of this revision.
zatrazz added a comment.

Updated patch based on previous comments. It depends on https://reviews.llvm.org/D58915. I am trying to come up with a testcase to actually test it. The the main difference for the cost analysis is just for some immediate that contains some 16-bit zero or one chunk (which will have the size adjusted from 3 to 2). Since they are not TCC_Free, TCC_Basic, or TCC_Expensive the change does not actually interfere in the further cost analysis.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58461/new/

https://reviews.llvm.org/D58461

Files:
  lib/Target/AArch64/AArch64TargetTransformInfo.cpp


Index: lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===================================================================
--- lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -8,6 +8,7 @@
 
 #include "AArch64TargetTransformInfo.h"
 #include "MCTargetDesc/AArch64AddressingModes.h"
+#include "MCTargetDesc/AArch64ExpandImm.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/CodeGen/BasicTTIImpl.h"
@@ -49,8 +50,9 @@
     Val = ~Val;
 
   // Calculate how many moves we will need to materialize this constant.
-  unsigned LZ = countLeadingZeros((uint64_t)Val);
-  return (64 - LZ + 15) / 16;
+  SmallVector<AArch64_IMM::ImmInsnModel, 4> Insn;
+  AArch64_IMM::expandMOVImm(Val, 64, Insn);
+  return Insn.size();
 }
 
 /// Calculate the cost of materializing the given constant.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58461.189177.patch
Type: text/x-patch
Size: 889 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190304/a07a8b1f/attachment.bin>


More information about the llvm-commits mailing list