[llvm] [CodeGen] Compact cost table entries (PR #202836)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 3 03:23:33 PDT 2026


================
@@ -17,24 +17,27 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/CodeGenTypes/MachineValueType.h"
+#include <cstdint>
 
 namespace llvm {
 
 /// Cost Table Entry
-template <typename CostType>
-struct CostTblEntryT {
-  int ISD;
-  MVT::SimpleValueType Type;
+template <typename CostType> struct CostTblEntryT {
+  // Cost tables use aggregate initialization, so values that do not fit in
+  // these fields are rejected as narrowing conversions at compile time.
+  uint16_t ISD;
+  uint8_t Type;
----------------
aengelke wrote:

LAST_VALUETYPE is 261, so unless we change MVT. For CostTblEntry, there's no difference anyway due to padding and TypeConversionCostTblEntry isn't used that often, so using MVT::SimpleValueType is probably preferable.

But I think we can change CostType to uint16_t (here and below).

https://github.com/llvm/llvm-project/pull/202836


More information about the llvm-commits mailing list