[PATCH] D119115: [RISCV] Improve insert_vector_elt for fixed mask registers.

Jianjian Guan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 10 19:32:54 PST 2022


jacquesguan added a comment.

In D119115#3309774 <https://reviews.llvm.org/D119115#3309774>, @craig.topper wrote:

> I may have an alternate suggestion for the bit manipulation
>
> %old_bit = srl %wideelt, %bitindex // shift old_bit to bit 0
> %b = xor %old_bit, new_bit // xor the old and new values together
> %c = andi %b, 1 // clear all bits except bit 0. This will clear all the extra bits from the shift and remove any extra bits that came with new_bit.
> %shl = shl %c, %bitindex // shift the xored value back to the correction position
> %xor = xor %wideelt, shl // at bitindex this will be old_bit^(old_bit^new_bit) which cancels to  new_bit. Every other index will xor with 0.
>
> This might be a shorter sequence, but I'm not sure.

Great idea, thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119115/new/

https://reviews.llvm.org/D119115



More information about the llvm-commits mailing list