Skip to content

Reduce bswap to smaller type #53867

@chfast

Description

@chfast

In some cases where shift is followed by bswap the bswap type may be reduced.
E.g.

  %2 = zext i16 %0 to i64
  %3 = shl nuw i64 %2, 48
  %4 = tail call i64 @llvm.bswap.i64(i64 %3)
  %5 = trunc i64 %4 to i16

should just be

  %2 = tail call i16 @llvm.bswap.i16(i16 %0)

https://godbolt.org/z/fq9e591EM
https://alive2.llvm.org/ce/z/rskDKL

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions