Issue |
141246
|
Summary |
[clang] odd code generation for `bool` promotion
|
Labels |
clang
|
Assignees |
|
Reporter |
samcowger
|
This C ([godbolt](https://godbolt.org/z/azaWPaxzz)):
```c
#include <stdbool.h>
int upcast(bool b) { return (b) ? 1 : 0; }
```
generates this x86_64 assembly:
```
upcast:
mov eax, edi
ret
```
If `b` has any of bits 1-31 set, then `upcast` would yield incorrect results. Is this appropriate? Does/should `clang` guarantee that `b` doesn't have arbitrary high-order bits set? FWIW, `gcc` generates ([godbolt](https://godbolt.org/z/xh1nqozfj)) a more restrictive `movzx` into `dil`:
```
upcast:
movzx eax, dil
ret
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs