[llvm] 2a1100c - [RISCV] Shrink the size of the RISCVMatInt::Inst.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 16:38:46 PST 2022


Author: Craig Topper
Date: 2022-12-07T16:38:39-08:00
New Revision: 2a1100cd656b1e65eba7a4a875d0be62191342b0

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

LOG: [RISCV] Shrink the size of the RISCVMatInt::Inst.

We don't need to store a full 64-bit immediate. The largest value
used by any opcode is 20 bits.

Using an int32_t shrinks the struct from 16 bytes to 8 bytes and
reduces the size of the SmallVector that we use to store sequences
by 64 bytes.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h
index 90c29f01c43d8..c330f5e161e3f 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h
@@ -27,9 +27,11 @@ enum OpndKind {
 
 struct Inst {
   unsigned Opc;
-  int64_t Imm;
+  int32_t Imm; // The largest value we need to store is 20 bits.
 
-  Inst(unsigned Opc, int64_t Imm) : Opc(Opc), Imm(Imm) {}
+  Inst(unsigned Opc, int64_t I) : Opc(Opc), Imm(I) {
+    assert(I == Imm && "truncated");
+  }
 
   OpndKind getOpndKind() const;
 };


        


More information about the llvm-commits mailing list