Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Sign Extension in SBPFv2 #32924

Closed as not planned
Closed as not planned
@Lichtso

Description

@Lichtso

Problem

Currently in the RBPF VM some ALU32 instructions do sign extend their 32 bit results (outputs) to 64 bit.

These operations sign extend their results from 32 bit to 64 bit:
ADD32, SUB32, NEG32, MUL32, LMUL32, SDIV32, SREM32

These operations do not:
DIV32, MOD32, XOR32, OR32, AND32, LSH32, RSH32, ARSH32, MOV32, UDIV32, UREM32

It is likely that most programs do not ever use the upper 32 bit of a u32 or i32 and thus this sign extension work is wasted and could be omitted.

Proposed Solution

Add an explicit sign extension instruction and remove implicit sign extension of results, see:
https://github.com/solana-foundation/solana-improvement-documents/pull/87/files

Metadata

Metadata

Assignees

Labels

stale[bot only] Added to stale content; results in auto-close after a week.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions