Skip to content

add swap_bytes#509

Closed
TheIronBorn wants to merge 2 commits intorust-lang:masterfrom
TheIronBorn:swap_bytes
Closed

add swap_bytes#509
TheIronBorn wants to merge 2 commits intorust-lang:masterfrom
TheIronBorn:swap_bytes

Conversation

@TheIronBorn
Copy link
Contributor

We could add some llvm.bswap implementations.

https://godbolt.org/g/jH2FCR suggests this could be better.

@TheIronBorn
Copy link
Contributor Author

I can't find a decent way to import the shuffle intrinsics

@TheIronBorn TheIronBorn force-pushed the swap_bytes branch 5 times, most recently from f5d7752 to e0c27a7 Compare June 29, 2018 22:44
@TheIronBorn TheIronBorn deleted the swap_bytes branch June 29, 2018 22:47
@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 30, 2018

You just need to do like x86 does and use the llvm intrinsics directly, they are in the llvm module.

@TheIronBorn
Copy link
Contributor Author

TheIronBorn commented Jun 30, 2018

I'm trying use coresimd::simd_llvm::*; but getting Could not find simd_llvm in coresimd (I closed this because I messed up a rebase, I'll open another later)

@TheIronBorn
Copy link
Contributor Author

TheIronBorn commented Jul 5, 2018

Using what I can see as the exact same technique used in codegen/mask_reductions:

#![allow(unused)]

use coresimd::simd::*;

pub(crate) trait SwapBytes {
    fn swap_bytes(self) -> Self;
}

impl SwapBytes for u8x2 {
    fn swap_bytes(self) -> Self {
        use coresimd::simd_llvm::simd_shuffle2;

        let shuffled: u8x2 = unsafe { simd_shuffle2(self, self, [1, 0]) };
        u8x2::from_bits(shuffled)
    }
}

Gets

error[E0432]: unresolved import `coresimd::simd_llvm`
  --> crates/coresimd/tests/../../../coresimd/ppsv/codegen/swap_bytes.rs:14:23
   |
14 |         use coresimd::simd_llvm::simd_shuffle2;
   |                       ^^^^^^^^^ Could not find `simd_llvm` in `coresimd`

Not sure what's going on.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 6, 2018

If you update or send a PR it is easier for me to look at it.

@TheIronBorn
Copy link
Contributor Author

I found a solution. The weird crate structure was throwing me. Pull coming soon

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 6, 2018

what was the problem?

@TheIronBorn
Copy link
Contributor Author

TheIronBorn commented Jul 6, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants