Lower small integer matches to a compare chain instead of a jump table

Đang mở
#15,510 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, wasm
Lĩnh vực
compilers

Hướng nghiên cứu

Start in src/base.rs at codegen_fn_body, where SwitchInt becomes a cranelift_frontend::Switch; compare that lowering with the issue’s icmp_imm_s and brif example. Check the reported classify and example/std_example.rs code sizes at -Copt_level=3; done means small integer matches use a compare chain when it reduces code size.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

cranelift enhancement

SwitchInt always becomes a cranelift_frontend::Switch (jump table plus an indirect branch). For a few cases, icmp_imm_s + brif per case in codegen_fn_body (src/base.rs) is smaller: classify 159 -> 142 bytes of .text at -Copt_level=3, example/std_example.rs 392779 -> 385371 (-1.9%).

#[no_mangle]
pub fn classify(x: u32) -> u32 { match x { 0 => 10, 1 => 11, 2 => 12, 3 => 13, _ => 0 } }
Ngôn ngữ chính
Rust
Star
18.9k
Fork
2k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
238

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytecodealliance/wasmtime

Tất cả issue của bytecodealliance/wasmtime

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.