Skip to content

Commit 5fb4224

Browse files
jakubjelinekChen Yixuan
authored andcommitted
bitint: Handle VCE from large/huge _BitInt SSA_NAME from load [PR114156]
When adding checks in which case not to merge a VIEW_CONVERT_EXPR from large/huge _BitInt to vector/complex etc., I missed the case of loads. Those are handled differently later. Anyway, I think the load case is something we can handle just fine, so the following patch does that instead of preventing the merging gimple_lower_bitint; we'd then copy from memory to memory and and do the vce only on the second one, it is just better to vce the first one. 2024-03-01 Jakub Jelinek <jakub@redhat.com> PR middle-end/114156 * gimple-lower-bitint.cc (bitint_large_huge::lower_stmt): Allow rhs1 of a VCE to have no underlying variable if it is a load and handle that case. * gcc.dg/bitint-96.c: New test.
1 parent b331418 commit 5fb4224

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

gcc/gimple-lower-bitint.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5153,6 +5153,22 @@ bitint_large_huge::lower_stmt (gimple *stmt)
51535153
gimple_assign_set_rhs1 (stmt, rhs1);
51545154
gimple_assign_set_rhs_code (stmt, SSA_NAME);
51555155
}
5156+
else if (m_names == NULL
5157+
|| !bitmap_bit_p (m_names, SSA_NAME_VERSION (rhs1)))
5158+
{
5159+
gimple *g = SSA_NAME_DEF_STMT (rhs1);
5160+
gcc_assert (gimple_assign_load_p (g));
5161+
tree mem = gimple_assign_rhs1 (g);
5162+
tree ltype = TREE_TYPE (lhs);
5163+
addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (mem));
5164+
if (as != TYPE_ADDR_SPACE (ltype))
5165+
ltype
5166+
= build_qualified_type (ltype,
5167+
TYPE_QUALS (ltype)
5168+
| ENCODE_QUAL_ADDR_SPACE (as));
5169+
rhs1 = build1 (VIEW_CONVERT_EXPR, ltype, mem);
5170+
gimple_assign_set_rhs1 (stmt, rhs1);
5171+
}
51565172
else
51575173
{
51585174
int part = var_to_partition (m_map, rhs1);

gcc/testsuite/gcc.dg/bitint-96.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* PR middle-end/114156 */
2+
/* { dg-do compile { target bitint } } */
3+
/* { dg-options "-O2" } */
4+
/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
5+
6+
#if __BITINT_MAXWIDTH__ >= 128
7+
_BitInt(128) a, b;
8+
#else
9+
int a, b;
10+
#endif
11+
12+
void
13+
foo (void)
14+
{
15+
int u = b;
16+
__builtin_memmove (&a, &b, sizeof (a));
17+
}

0 commit comments

Comments
 (0)