Skip to content

[AVR] Optimize 8-bit rotation #63100

Closed
Closed
@benshi001

Description

@benshi001

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions