Issue 53502
Summary [clang] missed optimization: bool addition not converted to boolean or
Labels new issue
Assignees
Reporter avikivity
    ```c++
bool bool_or(bool b1, bool b2) {
    return b1 + b2;
}
```

generates (clang 13)

```
bool_or(bool, bool):                           # @bool_or(bool, bool)
        negl    %esi
        cmpl    %esi, %edi
        setne   %al
        retq
```

However it can remove an instruction:

```
bool_or(bool, bool):                           # @bool_or(bool, bool)
        orl     %edi, %esi
        mov     %esi, %ax
        retq
```

Boolean multiplication generates an `andl` already.

This can happen when feeding std::plus<bool> to things like `std::reduce`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to