Home/Instructions/Shift Left Logical Immediate
SLLI

RISC-V SLLI Instruction Details

Instruction ManualI-type

Shift rs1 left logically by shamt bits (zeros into LSBs), result in rd

Instruction Syntax

slli rd, rs1, shamt
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
RV32IRV64IArithmeticShift

Instruction Behavior

SLLI is the I-type immediate logical left-shift form. It shifts rs1 left by shamt, fills low bits with zero, discards overflowed high bits, and writes the XLEN-truncated result to rd. RV32 uses imm[4:0] as shamt, range 0..31; RV64 uses a 6-bit shamt with imm[5] in bit25, while the remaining high bits are fixed for legal shift-immediate encodings. opcode=0010011, funct3=001.

SLLI Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rd
rs1
shamt
slli
,
,
Execution Context
t1(x6)
0x00000014
31..25
24..20
19..15
14..12
11..7
6..0
0000000
fixed imm[11:5]
00010
shamt[4:0]
00110
rs1
001
funct3
00101
rd
0010011
opcode
Execution Data Path
instruction
0x00231293
opcode
0010011 -> OP-IMM
funct3
001 -> SLLI
imm[11:5]
imm[11:5]=0000000 fixed
rd / rs1
t0(x5) / t1(x6)
imm[11:5] + shamt[4:0]
imm[11:5]=0000000 fixed; shamt[4:0]=00010
shift
0x00000014 << 2 = 0x00000050
x5
t0(x5) = 0x00000050
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x00231293
syntax : slli t0(x5), t1(x6), 2
result : t0(x5) = 0x00000050
Architectural Result
t0(x5) = 0x00000050

This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.

Quick Understanding & Search Notes

SLLI shifts rs1 left by the shamt constant in the syntax. It uses specialized shift-immediate encoding, not a normal signed imm[11:0] operand.

opcode=0010011 selects OP-IMM, and funct3=001 selects the left shift-immediate form.
RV32 has a 5-bit shamt; RV64 has a 6-bit shamt, so changing XLEN in the animation changes the valid range and bit25 meaning.

Common Usage Scenarios

Address & Pointer

Understand this scenario with real code like «slli x5, x6, 2 # x5 = low XLEN bits of (x6 << 2)».

Bit Operations & Masks

Understand this scenario with real code like «slli x5, x6, 2 # x5 = low XLEN bits of (x6 << 2)».

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

shamt must be a nonnegative encodable shift amount: 0..31 on RV32 and 0..63 on RV64.
SLLI is not an ordinary signed 12-bit immediate operation; high immediate bits are fixed encoding bits and, on RV64, part of the shift amount.

FAQ

What immediate range can SLLI encode?

As a shift amount, RV32 encodes 0..31 and RV64 encodes 0..63. It is not the ordinary -2048..2047 I-type arithmetic immediate.

Does SLLI keep bits shifted out on the left?

No. High bits shifted beyond XLEN are discarded, low bits are filled with zero, and rd receives only the XLEN-bit result.