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.
This commit is contained in:
Jakub Jelinek 2024-01-31 10:50:33 +01:00
parent 9bf91fa360
commit 90ac839a47
2 changed files with 18 additions and 0 deletions

View 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));

View file

@ -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