[llvm] [RISCV] Optimize (and (icmp x, 0, eq), (icmp y, 0, eq)) utilizing zicond extension (PR #166469)

Ryan Buchner via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 16:50:22 PST 2025


bababuck wrote:

> (and (icmp x, 0, eq), (icmp y, 0, eq)) can be done as (icmp eq (or x, y), 0) which is what InstCombine transforms it to. https://godbolt.org/z/Mq8z198eW

Do you think it is worthwhile to exclude for this specific case? I wouldn't expect this patch to interfere with that existing behavior since `instcombine` runs much earlier. Ran a quick test with the patch:
```
#include <stdbool.h>

bool foo(int a, int b) {
  return !a && !b;
}
```
./bin/clang -O3 -S -march=rv64gcbv_zicond_zvl512b c.c -o c.S
```
foo:                                    # @foo
# %bb.0:                                # %entry
        or      a0, a0, a1
        seqz    a0, a0
        ret
```

https://github.com/llvm/llvm-project/pull/166469


More information about the llvm-commits mailing list