mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-08 20:40:32 +00:00
Add comment about rustc-constant-info to blend function
This commit is contained in:
parent
28f10bc183
commit
cc8728b2a6
1 changed files with 20 additions and 0 deletions
|
|
@ -44,6 +44,26 @@ fn blend_lanes(x: u32x8, y: u32x8, control: Lanes) -> u32x8 {
|
||||||
unsafe {
|
unsafe {
|
||||||
use core::arch::x86_64::_mm256_blend_epi32;
|
use core::arch::x86_64::_mm256_blend_epi32;
|
||||||
|
|
||||||
|
// This would be much cleaner if we could factor out the match
|
||||||
|
// statement on the control. Unfortunately, rustc forgets
|
||||||
|
// constant-info very quickly, so we can't even write
|
||||||
|
// ```
|
||||||
|
// match control {
|
||||||
|
// Lanes::C => {
|
||||||
|
// let imm = C_LANES as i32;
|
||||||
|
// _mm256_blend_epi32(..., imm)
|
||||||
|
// ```
|
||||||
|
// let alone
|
||||||
|
// ```
|
||||||
|
// let imm = match control {
|
||||||
|
// Lanes::C => C_LANES as i32,
|
||||||
|
// }
|
||||||
|
// _mm256_blend_epi32(..., imm)
|
||||||
|
// ```
|
||||||
|
// even though both of these would be constant-folded by LLVM
|
||||||
|
// at a lower level (as happens in the shuffle implementation,
|
||||||
|
// which does not require a shuffle immediate but *is* lowered
|
||||||
|
// to immediate shuffles anyways).
|
||||||
match control {
|
match control {
|
||||||
Lanes::C => {
|
Lanes::C => {
|
||||||
_mm256_blend_epi32(x.into_bits(), y.into_bits(), C_LANES as i32).into_bits()
|
_mm256_blend_epi32(x.into_bits(), y.into_bits(), C_LANES as i32).into_bits()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue