https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119402
Bug ID: 119402 Summary: [14/15 Regression] `((-bool) & _6) & (~_6)` is not optimized to 0 on some targets Product: gcc Version: 14.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: aarch64 While looking into PR 119291, I accidently found this. It is not the issue in PR 119291 but does look like influences it. ``` __attribute__((noipa)) int x(_Bool iftmp, unsigned _6) { return ((-iftmp) & _6) & (~_6); } __attribute__((noipa)) int y(_Bool iftmp, unsigned _6) { return (iftmp * _6) & (~_6); } __attribute__((noipa)) int z(_Bool iftmp, unsigned _6) { unsigned t = ~_6; unsigned t1 = (iftmp ? _6 : 0); return t1 & t; } ``` All of these should always optimize to 0. But only z is able to do it on the trunk/GCC 14. In GCC 13, all three can. In GCC 12 x and z can.