https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111126
Bug ID: 111126 Summary: Not always using czero.eqz Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: riscv* (with zicond) Take: ``` int f(bool a, int c) { return a * c; } int f0(bool a, int c) { return (-a) & c; } int f1(bool a, int c) { return a ? c : 0; } int f3(int a, int b, int c) { return (a == b) * c; } int g0(bool a, int c) { return a ? 0 : c; } int g1(bool a, int c) { a = !a; return a * c; } ``` Currently for f, f0 we emit: ``` neg a0,a0 and a0,a0,a1 ``` Which is good for riscv without zicond but with we should just get the same as f1. f1 we do we: ``` czero.eqz a0,a1,a0 ``` though without zicond we get: ``` snez a5,a0 neg a5,a5 and a0,a1,a5 ``` Notice the extra snez (note the above is because that is ifcvt.cc doing the emitting). This is all about what is the canonical form of bool ? a : 0.