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_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));
--- /dev/null
+/* 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