* [PATCH] tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508]
@ 2023-07-02 14:53 Jakub Jelinek
2023-07-02 15:23 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-07-02 14:53 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
The match_uaddc_usubc matching doesn't require that the second
.{ADD,SUB}_OVERFLOW has REALPART_EXPR of its lhs used, only that there is
at most one. So, in the weird case where the REALPART_EXPR of it isn't
present, we shouldn't ICE trying to replace that REALPART_EXPR with
REALPART_EXPR of .U{ADD,SUB}C result.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2023-07-02 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/110508
* tree-ssa-math-opts.cc (match_uaddc_usubc): Only replace re2 with
REALPART_EXPR opf nlhs if re2 is non-NULL.
* gcc.dg/pr110508.c: New test.
--- gcc/tree-ssa-math-opts.cc.jj 2023-06-20 11:22:26.726887276 +0200
+++ gcc/tree-ssa-math-opts.cc 2023-07-01 00:29:48.554230914 +0200
@@ -4856,11 +4856,14 @@ match_uaddc_usubc (gimple_stmt_iterator
gsi_remove (&gsi2, true);
/* Replace the re2 statement with __real__ of the newly added
.UADDC/.USUBC call. */
- gsi2 = gsi_for_stmt (re2);
- tree rlhs = gimple_assign_lhs (re2);
- g = gimple_build_assign (rlhs, REALPART_EXPR,
- build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs));
- gsi_replace (&gsi2, g, true);
+ if (re2)
+ {
+ gsi2 = gsi_for_stmt (re2);
+ tree rlhs = gimple_assign_lhs (re2);
+ g = gimple_build_assign (rlhs, REALPART_EXPR,
+ build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs));
+ gsi_replace (&gsi2, g, true);
+ }
if (rhs[2])
{
/* If this is the arg1 + arg2 + (ovf1 + ovf2) or
--- gcc/testsuite/gcc.dg/pr110508.c.jj 2023-07-01 00:33:12.494405901 +0200
+++ gcc/testsuite/gcc.dg/pr110508.c 2023-07-01 00:32:24.115075870 +0200
@@ -0,0 +1,9 @@
+/* PR tree-optimization/110508 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (unsigned a, unsigned b, unsigned *c, _Bool d)
+{
+ __builtin_addc (a, b, d, c);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508]
2023-07-02 14:53 [PATCH] tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508] Jakub Jelinek
@ 2023-07-02 15:23 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-07-02 15:23 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
> Am 02.07.2023 um 16:54 schrieb Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>:
>
> Hi!
>
> The match_uaddc_usubc matching doesn't require that the second
> .{ADD,SUB}_OVERFLOW has REALPART_EXPR of its lhs used, only that there is
> at most one. So, in the weird case where the REALPART_EXPR of it isn't
> present, we shouldn't ICE trying to replace that REALPART_EXPR with
> REALPART_EXPR of .U{ADD,SUB}C result.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok
Richard
> 2023-07-02 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/110508
> * tree-ssa-math-opts.cc (match_uaddc_usubc): Only replace re2 with
> REALPART_EXPR opf nlhs if re2 is non-NULL.
>
> * gcc.dg/pr110508.c: New test.
>
> --- gcc/tree-ssa-math-opts.cc.jj 2023-06-20 11:22:26.726887276 +0200
> +++ gcc/tree-ssa-math-opts.cc 2023-07-01 00:29:48.554230914 +0200
> @@ -4856,11 +4856,14 @@ match_uaddc_usubc (gimple_stmt_iterator
> gsi_remove (&gsi2, true);
> /* Replace the re2 statement with __real__ of the newly added
> .UADDC/.USUBC call. */
> - gsi2 = gsi_for_stmt (re2);
> - tree rlhs = gimple_assign_lhs (re2);
> - g = gimple_build_assign (rlhs, REALPART_EXPR,
> - build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs));
> - gsi_replace (&gsi2, g, true);
> + if (re2)
> + {
> + gsi2 = gsi_for_stmt (re2);
> + tree rlhs = gimple_assign_lhs (re2);
> + g = gimple_build_assign (rlhs, REALPART_EXPR,
> + build1 (REALPART_EXPR, TREE_TYPE (rlhs), nlhs));
> + gsi_replace (&gsi2, g, true);
> + }
> if (rhs[2])
> {
> /* If this is the arg1 + arg2 + (ovf1 + ovf2) or
> --- gcc/testsuite/gcc.dg/pr110508.c.jj 2023-07-01 00:33:12.494405901 +0200
> +++ gcc/testsuite/gcc.dg/pr110508.c 2023-07-01 00:32:24.115075870 +0200
> @@ -0,0 +1,9 @@
> +/* PR tree-optimization/110508 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +void
> +foo (unsigned a, unsigned b, unsigned *c, _Bool d)
> +{
> + __builtin_addc (a, b, d, c);
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-02 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-02 14:53 [PATCH] tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508] Jakub Jelinek
2023-07-02 15:23 ` 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).