https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92408
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:1649ee187dfdb89f52e6acf15525465f77b67a64 commit r17-2695-g1649ee187dfdb89f52e6acf15525465f77b67a64 Author: Ashley Chekhova <[email protected]> Date: Fri Jul 24 23:26:43 2026 -0600 [PATCH v2] tree-optimization: Fix strlen(s) != 0 not folded into *s [PR92408] Checks for strlen(s) == 0 could be rewritten as *s == 0 in the simple case, but in complex cases (such as those involving variable assignment), the optimization wouldn't be implemented. Fix this by moving it over to forwprop from fold-const. Although, since this currently only runs when PROP_last_full_fold is set, the original code is kept in as well. Bootstrapped and tested on x86_64-pc-linux-gnu PR tree-optimization/92408 gcc/ChangeLog: * tree-ssa-forwprop.cc (optimize_strlen_comp): Rewrite strlen(s) == 0 as *s == 0 and strlen(s) != 0 as *s != 0. (simplify_builtin_call): Added call to optimize_strlen_comp. gcc/testsuite/ChangeLog: * gcc.dg/pr92408.c: New test.
