diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-lower-bitint.cc | 26 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/bitint-53.c | 17 |
2 files changed, 28 insertions, 15 deletions
diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 65a7bbe..d52e4c4 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -405,7 +405,7 @@ struct bitint_large_huge profile_probability, profile_probability, edge &, edge &, edge &); tree handle_operand (tree, tree); - tree prepare_data_in_out (tree, tree, tree *); + tree prepare_data_in_out (tree, tree, tree *, tree = NULL_TREE); tree add_cast (tree, tree); tree handle_plus_minus (tree_code, tree, tree, tree); tree handle_lshift (tree, tree, tree); @@ -873,11 +873,8 @@ bitint_large_huge::handle_operand (tree op, tree idx) gcc_assert (m_first); m_data.pop (); m_data.pop (); - prepare_data_in_out (fold_convert (m_limb_type, op), idx, &out); - g = gimple_build_assign (m_data[m_data_cnt + 1], - build_int_cst (m_limb_type, ext)); - insert_before (g); - m_data[m_data_cnt + 1] = gimple_assign_rhs1 (g); + prepare_data_in_out (fold_convert (m_limb_type, op), idx, &out, + build_int_cst (m_limb_type, ext)); } else if (min_prec > prec - rem - 2 * limb_prec) { @@ -1009,10 +1006,13 @@ bitint_large_huge::handle_operand (tree op, tree idx) /* Helper method, add a PHI node with VAL from preheader edge if inside of a loop and m_first. Keep state in a pair of m_data - elements. */ + elements. If VAL_OUT is non-NULL, use that as PHI argument from + the latch edge, otherwise create a new SSA_NAME for it and let + caller initialize it. */ tree -bitint_large_huge::prepare_data_in_out (tree val, tree idx, tree *data_out) +bitint_large_huge::prepare_data_in_out (tree val, tree idx, tree *data_out, + tree val_out) { if (!m_first) { @@ -1035,7 +1035,7 @@ bitint_large_huge::prepare_data_in_out (tree val, tree idx, tree *data_out) if (e1 == e2) e2 = EDGE_PRED (m_bb, 1); add_phi_arg (phi, val, e1, UNKNOWN_LOCATION); - tree out = make_ssa_name (TREE_TYPE (val)); + tree out = val_out ? val_out : make_ssa_name (TREE_TYPE (val)); add_phi_arg (phi, out, e2, UNKNOWN_LOCATION); m_data.safe_push (in); m_data.safe_push (out); @@ -1542,14 +1542,10 @@ bitint_large_huge::handle_cast (tree lhs_type, tree rhs1, tree idx) if (m_first) { tree out1, out2; - prepare_data_in_out (r1, idx, &out1); - g = gimple_build_assign (m_data[m_data_cnt + 1], rext); - insert_before (g); + prepare_data_in_out (r1, idx, &out1, rext); if (TYPE_PRECISION (rhs_type) > limb_prec) { - prepare_data_in_out (r2, idx, &out2); - g = gimple_build_assign (m_data[m_data_cnt + 3], rext); - insert_before (g); + prepare_data_in_out (r2, idx, &out2, rext); m_data.pop (); t = m_data.pop (); m_data[m_data_cnt + 1] = t; diff --git a/gcc/testsuite/gcc.dg/bitint-53.c b/gcc/testsuite/gcc.dg/bitint-53.c new file mode 100644 index 0000000..2474660 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-53.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/112940 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23 -O2" } */ + +#if __BITINT_MAXWIDTH__ >= 1025 +_BitInt (1025) b; +#endif + +void +foo (long x) +{ +#if __BITINT_MAXWIDTH__ >= 1025 + b += (unsigned _BitInt (255)) x; +#else + (void) x; +#endif +} |