Skip to content

[AVR] Optimize 8-bit rotation #63100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
benshi001 opened this issue Jun 4, 2023 · 0 comments
Closed

[AVR] Optimize 8-bit rotation #63100

benshi001 opened this issue Jun 4, 2023 · 0 comments

Comments

@benshi001
Copy link
Member

benshi001 commented Jun 4, 2023

For the following a.ll,

define i8 @test(i8 %0) {
start:
  %1 = call i8 @llvm.fshr.i8(i8 %0, i8 %0, i8 4)
  ret i8 %1
}

declare i8 @llvm.fshr.i8(i8, i8, i8)

Build it with llc a.ll -march=avr -mcpu=atmega328, the following assembly is generated,

        .type   test,@function
test:                                   ; @test
; %bb.0:                                ; %start
        bst     r24, 0
        ror     r24
        bld     r24, 7
        bst     r24, 0
        ror     r24
        bld     r24, 7
        bst     r24, 0
        ror     r24
        bld     r24, 7
        bst     r24, 0
        ror     r24
        bld     r24, 7
        ret

which could be optimized to a single swap r24.

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

No branches or pull requests

2 participants