]> gcc.gnu.org Git - gcc.git/commitdiff
lower-bitint: Fix up VIEW_CONVERT_EXPR handling in handle_operand_addr [PR113639]
authorJakub Jelinek <jakub@redhat.com>
Wed, 31 Jan 2024 09:50:33 +0000 (10:50 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 31 Jan 2024 09:55:42 +0000 (10:55 +0100)
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.

gcc/gimple-lower-bitint.cc
gcc/testsuite/gcc.dg/bitint-79.c [new file with mode: 0644]

index af167450ec0562dfa9ca83ec826b05894cfc202d..a3802c61816a561be5a165efafc75d8d1dcf2fe8 100644 (file)
@@ -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 (file)
index 0000000..e7422c0
--- /dev/null
@@ -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
This page took 0.073124 seconds and 5 git commands to generate.