* [PATCH] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408]
@ 2024-01-17 9:46 Jakub Jelinek
2024-01-17 12:09 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-01-17 9:46 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR
is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped
in VIEW_CONVERT_EXPR tree.
So, to handle it like other casts we need to look through it.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2024-01-17 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/113408
* gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For
VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1
to handle_cast.
* gcc.dg/bitint-71.c: New test.
--- gcc/gimple-lower-bitint.cc.jj 2024-01-15 17:34:00.000000000 +0100
+++ gcc/gimple-lower-bitint.cc 2024-01-16 12:32:56.617721208 +0100
@@ -1975,9 +1975,12 @@ bitint_large_huge::handle_stmt (gimple *
case INTEGER_CST:
return handle_operand (gimple_assign_rhs1 (stmt), idx);
CASE_CONVERT:
- case VIEW_CONVERT_EXPR:
return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)),
gimple_assign_rhs1 (stmt), idx);
+ case VIEW_CONVERT_EXPR:
+ return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)),
+ TREE_OPERAND (gimple_assign_rhs1 (stmt), 0),
+ idx);
default:
break;
}
--- gcc/testsuite/gcc.dg/bitint-71.c.jj 2024-01-16 12:38:16.679239526 +0100
+++ gcc/testsuite/gcc.dg/bitint-71.c 2024-01-16 12:37:24.724967020 +0100
@@ -0,0 +1,18 @@
+/* PR tree-optimization/113408 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c23 -O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 713
+struct A { _BitInt(713) b; } g;
+#else
+struct A { _BitInt(49) b; } g;
+#endif
+int f;
+
+void
+foo (void)
+{
+ struct A j = g;
+ if (j.b)
+ f = 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408]
2024-01-17 9:46 [PATCH] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408] Jakub Jelinek
@ 2024-01-17 12:09 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-01-17 12:09 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Wed, 17 Jan 2024, Jakub Jelinek wrote:
> Hi!
>
> Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR
> is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped
> in VIEW_CONVERT_EXPR tree.
>
> So, to handle it like other casts we need to look through it.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
> 2024-01-17 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/113408
> * gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For
> VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1
> to handle_cast.
>
> * gcc.dg/bitint-71.c: New test.
>
> --- gcc/gimple-lower-bitint.cc.jj 2024-01-15 17:34:00.000000000 +0100
> +++ gcc/gimple-lower-bitint.cc 2024-01-16 12:32:56.617721208 +0100
> @@ -1975,9 +1975,12 @@ bitint_large_huge::handle_stmt (gimple *
> case INTEGER_CST:
> return handle_operand (gimple_assign_rhs1 (stmt), idx);
> CASE_CONVERT:
> - case VIEW_CONVERT_EXPR:
> return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)),
> gimple_assign_rhs1 (stmt), idx);
> + case VIEW_CONVERT_EXPR:
> + return handle_cast (TREE_TYPE (gimple_assign_lhs (stmt)),
> + TREE_OPERAND (gimple_assign_rhs1 (stmt), 0),
> + idx);
> default:
> break;
> }
> --- gcc/testsuite/gcc.dg/bitint-71.c.jj 2024-01-16 12:38:16.679239526 +0100
> +++ gcc/testsuite/gcc.dg/bitint-71.c 2024-01-16 12:37:24.724967020 +0100
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/113408 */
> +/* { dg-do compile { target bitint } } */
> +/* { dg-options "-std=c23 -O2" } */
> +
> +#if __BITINT_MAXWIDTH__ >= 713
> +struct A { _BitInt(713) b; } g;
> +#else
> +struct A { _BitInt(49) b; } g;
> +#endif
> +int f;
> +
> +void
> +foo (void)
> +{
> + struct A j = g;
> + if (j.b)
> + f = 0;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-17 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 9:46 [PATCH] lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408] Jakub Jelinek
2024-01-17 12:09 ` 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).