summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-03-01 11:04:51 +0100
committerJakub Jelinek <jakub@redhat.com>2024-03-01 11:04:51 +0100
commitd3d0fcb652748191714e4c0b2541e977a7fc7bd7 (patch)
treec7b66ed76f7fc924ece16dea7daa70586bb3a3a3
parentc6d4fb0062c6059fe21968a9fe44c56814c88873 (diff)
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.
-rw-r--r--gcc/gimple-lower-bitint.cc16
-rw-r--r--gcc/testsuite/gcc.dg/bitint-96.c17
2 files changed, 33 insertions, 0 deletions
diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index d7bf029973c..15a27126d44 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -5329,6 +5329,22 @@ bitint_large_huge::lower_stmt (gimple *stmt)
gimple_assign_set_rhs1 (stmt, rhs1);
gimple_assign_set_rhs_code (stmt, SSA_NAME);
}
+ else if (m_names == NULL
+ || !bitmap_bit_p (m_names, SSA_NAME_VERSION (rhs1)))
+ {
+ gimple *g = SSA_NAME_DEF_STMT (rhs1);
+ gcc_assert (gimple_assign_load_p (g));
+ tree mem = gimple_assign_rhs1 (g);
+ tree ltype = TREE_TYPE (lhs);
+ addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (mem));
+ if (as != TYPE_ADDR_SPACE (ltype))
+ ltype
+ = build_qualified_type (ltype,
+ TYPE_QUALS (ltype)
+ | ENCODE_QUAL_ADDR_SPACE (as));
+ rhs1 = build1 (VIEW_CONVERT_EXPR, ltype, mem);
+ gimple_assign_set_rhs1 (stmt, rhs1);
+ }
else
{
int part = var_to_partition (m_map, rhs1);
diff --git a/gcc/testsuite/gcc.dg/bitint-96.c b/gcc/testsuite/gcc.dg/bitint-96.c
new file mode 100644
index 00000000000..237eb47a9f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-96.c
@@ -0,0 +1,17 @@
+/* PR middle-end/114156 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
+
+#if __BITINT_MAXWIDTH__ >= 128
+_BitInt(128) a, b;
+#else
+int a, b;
+#endif
+
+void
+foo (void)
+{
+ int u = b;
+ __builtin_memmove (&a, &b, sizeof (a));
+}