File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -965,6 +965,19 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
965
965
} } ;
966
966
}
967
967
968
+ /// Converts a vector mask, where each element has a bit width equal to the data elements it is used with,
969
+ /// down to an i1 based mask that can be used by llvm intrinsics.
970
+ ///
971
+ /// The rust simd semantics are that each element should either consist of all ones or all zeroes,
972
+ /// but this information is not available to llvm. Truncating the vector effectively uses the lowest bit,
973
+ /// but codegen for several targets is better if we consider the highest bit by shifting.
974
+ ///
975
+ /// For x86 SSE/AVX targets this is beneficial since most instructions with mask parameters only consider the highest bit.
976
+ /// So even though on llvm level we have an additional shift, in the final assembly there is no shift or truncate and
977
+ /// instead the mask can be used as is.
978
+ ///
979
+ /// For aarch64 and other targets there is a benefit because a mask from the sign bit can be more
980
+ /// efficiently converted to an all ones / all zeroes mask by comparing whether each element is negative.
968
981
fn vector_mask_to_bitmask < ' a , ' ll , ' tcx > (
969
982
bx : & mut Builder < ' a , ' ll , ' tcx > ,
970
983
i_xn : & ' ll Value ,
You can’t perform that action at this time.
0 commit comments