Skip to content

Unexpected codegen for __builtin_elementwise_bitreverse on unsigned char and short  #84047

Closed
@shafik

Description

@shafik

Given the following: https://godbolt.org/z/M1hEqs9q5

unsigned char f(unsigned char a) {
  return __builtin_elementwise_bitreverse(a);
}

unsigned short f(unsigned short a) {
  return __builtin_elementwise_bitreverse(a);
}

signed char f3(signed char a) {
  return __builtin_elementwise_bitreverse(a);
}

signed short f3(signed short a) {
  return __builtin_elementwise_bitreverse(a);
}

for the unsigned char and unsigned short cases it automatically returns 0 w/ any level of optimization e.g.

define dso_local noundef zeroext i8 @f(unsigned char)(i8 noundef zeroext %a) local_unnamed_addr {
entry:
  tail call void @llvm.dbg.value(metadata i8 %a, metadata !16, metadata !DIExpression())
  ret i8 0
}

Based on the documentation: https://clang.llvm.org/docs/LanguageExtensions.html

This is not expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions