public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8650] lower-bitint: Fix up VIEW_CONVERT_EXPR handling in handle_operand_addr [PR113639]
@ 2024-01-31  9:55 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2024-01-31  9:55 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:90ac839a470d61ffcd9eee0d7d37ca9c385dfefb

commit r14-8650-g90ac839a470d61ffcd9eee0d7d37ca9c385dfefb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 31 10:50:33 2024 +0100

    lower-bitint: Fix up VIEW_CONVERT_EXPR handling in handle_operand_addr [PR113639]
    
    Yet another spot where we need to treat VIEW_CONVERT_EXPR differently
    from NOP_EXPR/CONVERT_EXPR.
    
    2024-01-31  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/113639
            * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr):
            For VIEW_CONVERT_EXPR set rhs1 to its operand.
    
            * gcc.dg/bitint-79.c: New test.

Diff:
---
 gcc/gimple-lower-bitint.cc       |  2 ++
 gcc/testsuite/gcc.dg/bitint-79.c | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index af167450ec05..a3802c61816a 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -2159,6 +2159,8 @@ bitint_large_huge::handle_operand_addr (tree op, gimple *stmt,
 	      gcc_assert (gimple_assign_cast_p (g));
 	      tree rhs1 = gimple_assign_rhs1 (g);
 	      bitint_prec_kind kind = bitint_prec_small;
+	      if (TREE_CODE (rhs1) == VIEW_CONVERT_EXPR)
+		rhs1 = TREE_OPERAND (rhs1, 0);
 	      gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)));
 	      if (TREE_CODE (TREE_TYPE (rhs1)) == BITINT_TYPE)
 		kind = bitint_precision_kind (TREE_TYPE (rhs1));
diff --git a/gcc/testsuite/gcc.dg/bitint-79.c b/gcc/testsuite/gcc.dg/bitint-79.c
new file mode 100644
index 000000000000..e7422c06acf7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-79.c
@@ -0,0 +1,16 @@
+/* PR tree-optimization/113639 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -std=c23" } */
+
+int j, k;
+#if __BITINT_MAXWIDTH__ >= 162
+struct S { _BitInt(162) n; };
+void bar (_BitInt(162) x);
+
+void
+foo (struct S s)
+{
+  bar (s.n * j);
+  (void) (s.n * k);
+}
+#endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-31  9:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31  9:55 [gcc r14-8650] lower-bitint: Fix up VIEW_CONVERT_EXPR handling in handle_operand_addr [PR113639] Jakub Jelinek

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).