* [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258]
@ 2023-03-24 9:07 Jakub Jelinek
2023-03-24 9:08 ` Jakub Jelinek
2023-03-24 9:30 ` Richard Biener
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2023-03-24 9:07 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
The PR109086 r13-6690 inline_string_cmp change to
if (diff != result)
emit_move_insn (result, diff);
regressed
FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224)
The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also
send patch for that) and so result is const0_rtx when the call lost its lhs
and the above move ICEs because moving something into const0_rtx is obviously
invalid.
I think it is better not to rely on all FEs having these *cmp functions
pure anD DCE being performed. The following patch just punts from the
inline expansion in that case, so we just emit normal library call.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2023-03-24 Jakub Jelinek <jakub@redhat.com>
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
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258]
2023-03-24 9:07 [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258] Jakub Jelinek
@ 2023-03-24 9:08 ` Jakub Jelinek
2023-03-24 9:30 ` Richard Biener
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2023-03-24 9:08 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
The PR109086 r13-6690 inline_string_cmp change to
if (diff != result)
emit_move_insn (result, diff);
regressed
FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224)
The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also
send patch for that) and so result is const0_rtx when the call lost its lhs
and the above move ICEs because moving something into const0_rtx is obviously
invalid.
I think it is better not to rely on all FEs having these *cmp functions
pure anD DCE being performed. The following patch just punts from the
inline expansion in that case, so we just emit normal library call.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2023-03-24 Jakub Jelinek <jakub@redhat.com>
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
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258]
2023-03-24 9:07 [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258] Jakub Jelinek
2023-03-24 9:08 ` Jakub Jelinek
@ 2023-03-24 9:30 ` Richard Biener
1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-03-24 9:30 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Fri, 24 Mar 2023, Jakub Jelinek wrote:
> Hi!
>
> The PR109086 r13-6690 inline_string_cmp change to
> if (diff != result)
> emit_move_insn (result, diff);
> regressed
> FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224)
> The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also
> send patch for that) and so result is const0_rtx when the call lost its lhs
> and the above move ICEs because moving something into const0_rtx is obviously
> invalid.
> I think it is better not to rely on all FEs having these *cmp functions
> pure anD DCE being performed. The following patch just punts from the
> inline expansion in that case, so we just emit normal library call.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
> 2023-03-24 Jakub Jelinek <jakub@redhat.com>
>
> 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
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-24 9:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 9:07 [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258] Jakub Jelinek
2023-03-24 9:08 ` Jakub Jelinek
2023-03-24 9:30 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).