On 10/15/23 02:14, Roger Sayle wrote:
I’ve done it again. ENOPATCH.

*From:*Roger Sayle <ro...@nextmovesoftware.com>
*Sent:* 15 October 2023 09:13
*To:* 'gcc-patches@gcc.gnu.org' <gcc-patches@gcc.gnu.org>
*Cc:* 'Claudiu Zissulescu' <claz...@gmail.com>
*Subject:* [ARC PATCH] Split asl dst,1,src into bset dst,0,src to implement 1<<x.

This patch adds a pre-reload splitter to arc.md, to use the bset (set

specific bit instruction) to implement 1<<x (i.e. left shifts of one)

on ARC processors that don't have a barrel shifter.

Currently,

int foo(int x) {

   return 1 << x;

}
The same basic idea works on the H8, though it's got restrictions that make it not actually useful in practice.

In particular the H8's bset instruction only looks at the bottom 3 bits of the count. So unless there's a suitable masking of the count or the destination register is QImode, then it's not useful ;(

That's too bad, avoiding the shift loop for this kind of source construct would definitely be a win.

jeff


Reply via email to