[llvm] [NVPTX] Use PRMT instruction to lower i16 bswap (PR #168968)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 19:18:39 PST 2025


AlexMaclean wrote:

> > If you wanted to go above and beyond, I think it would be best to instead implement this (and all other bswap expansion) as a custom legalization to allow for DAGCombiner to optimize them.
> 
> I see. Do you mean that we just lower all the bswap into bit operations first and let DAGCombiner decide how to optimize using PRMT?

sorta, something along the lines of `LowerVECTOR_SHUFFLE`. That is use the NVPTXISD::PRTM node plus zext, trunc to represent this same expansion during operation legalization (instead of in ISel where it is now). Does that make sense?

https://github.com/llvm/llvm-project/pull/168968


More information about the llvm-commits mailing list