[Bug tree-optimization/109638] unsigned > 1 ? 0 : n is not optimized to n == 1

2023-09-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109638 Andrew Pinski changed: What|Removed |Added Resolution|--- |FIXED Target Milestone|---

[Bug tree-optimization/109638] unsigned > 1 ? 0 : n is not optimized to n == 1

2023-04-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109638 --- Comment #2 from Richard Biener --- Hmm, but more generally if (n != x) n = 0; return n != 0; could be handled as well. Or if (n != x) n = 0; return n; -> return (n == x) * x; -1 might be another special case that CPUs can

[Bug tree-optimization/109638] unsigned > 1 ? 0 : n is not optimized to n == 1

2023-04-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109638 --- Comment #1 from Andrew Pinski --- This should do it, I think: (simplify (cond (lt @1 integer_onep@2) integer_zerop @1) (if (TYPE_UNSIGNED (type)) (convert (eq @1 @2