llvm / llvm/llvm-project

[InstCombine] bool mul (from memory) generated mul instead of and

Closed
#214,333 2 comments 0 reactions 1 assignee Claimed by @i-nahc View on GitHub
llvm:instcombine missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
bool foo(bool & a, bool & b){
return a*b;
}
```
gcc:
```asm
"foo(bool&, bool&)":
movzx eax, BYTE PTR [rdi]
and al, BYTE PTR [rsi]
ret
```
clang:
```asm
foo(bool&, bool&):
movzx eax, byte ptr [rsi]
mul byte ptr [rdi]
ret
```
https://godbolt.org/z/ex3aj3KPb

Not sure if this is a clang or InstCombine problem, but simply replacing mul with and doesn't satisfy alive2.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.