https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109258
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
One possible fix is
2023-03-23 Jakub Jelinek <[email protected]>
PR middle-end/109258
* builtins.cc (inline_expand_builtin_bytecmp): Return NULL_RTX early
if target == const0_rtx.
--- gcc/builtins.cc.jj 2023-03-23 10:00:58.308100548 +0100
+++ gcc/builtins.cc 2023-03-23 11:05:38.308135309 +0100
@@ -7178,8 +7178,8 @@ inline_expand_builtin_bytecmp (tree exp,
bool is_ncmp = (fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP);
/* Do NOT apply this inlining expansion when optimizing for size or
- optimization level below 2. */
- if (optimize < 2 || optimize_insn_for_size_p ())
+ optimization level below 2 or if unused *cmp hasn't been DCEd. */
+ if (optimize < 2 || optimize_insn_for_size_p () || target == const0_rtx)
return NULL_RTX;
gcc_checking_assert (fcode == BUILT_IN_STRCMP