about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorJörn Horstmann <git@jhorstmann.net>2023-01-04 23:55:40 +0100
committerJörn Horstmann <git@jhorstmann.net>2025-01-26 16:44:23 +0100
commit3779b8e32e405e81d234531a3b4e29ed3c13db8e (patch)
treeec8e4cddccff5e8338668e21731ce3243c804f87 /compiler/rustc_codegen_llvm/src/errors.rs
parentc2270becb63d4c52a2740137db2e9b49246f9362 (diff)
downloadrust-3779b8e32e405e81d234531a3b4e29ed3c13db8e.tar.gz
rust-3779b8e32e405e81d234531a3b4e29ed3c13db8e.zip
Consistently use the most significant bit of vector masks
This improves the codegen for vector `select`, `gather`, `scatter` and
boolean reduction intrinsics and fixes rust-lang/portable-simd#316.

The current behavior of most mask operations during llvm codegen is to
truncate the mask vector to <N x i1>, telling llvm to use the least
significat bit. The exception is the `simd_bitmask` intrinsics, which
already used the most signifiant bit.

Since sse/avx instructions are defined to use the most significant bit,
truncating means that llvm has to insert a left shift to move the bit
into the most significant position, before the mask can actually be
used.

Similarly on aarch64, mask operations like blend work bit by bit,
repeating the least significant bit across the whole lane involves
shifting it into the sign position and then comparing against zero.

By shifting before truncating to <N x i1>, we tell llvm that we only
consider the most significant bit, removing the need for additional
shift instructions in the assembly.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions