aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-12-22 12:28:54 +0100
committerJakub Jelinek <jakub@redhat.com>2023-12-22 12:28:54 +0100
commit0a6aa1927597d821a85bc3d1fd7682256c25b548 (patch)
tree8c794f478b2f30677f895c4eaf5dac98036106d7 /gcc
parentf5198f0264e773d3b5d55f09a579313b0b231527 (diff)
downloadgcc-0a6aa1927597d821a85bc3d1fd7682256c25b548.zip
gcc-0a6aa1927597d821a85bc3d1fd7682256c25b548.tar.gz
gcc-0a6aa1927597d821a85bc3d1fd7682256c25b548.tar.bz2
symtab-thunks: Use aggregate_value_p even on is_gimple_reg_type returns [PR112941]
Large/huge _BitInt types are returned in memory and the bitint lowering pass right now relies on that. The gimplification etc. use aggregate_value_p to see if it should be returned in memory or not and use <retval> = _123; return <retval>; rather than return _123; But expand_thunk used e.g. by IPA-ICF was performing an optimization, assuming is_gimple_reg_type is always passed in registers and not calling aggregate_value_p in that case. The following patch changes it to match what the gimplification etc. are doing. 2023-12-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/112941 * symtab-thunks.cc (expand_thunk): Check aggregate_value_p regardless of whether is_gimple_reg_type (restype) or not. * gcc.dg/bitint-60.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/symtab-thunks.cc18
-rw-r--r--gcc/testsuite/gcc.dg/bitint-60.c20
2 files changed, 26 insertions, 12 deletions
diff --git a/gcc/symtab-thunks.cc b/gcc/symtab-thunks.cc
index 23ead0d..0e5fc4f 100644
--- a/gcc/symtab-thunks.cc
+++ b/gcc/symtab-thunks.cc
@@ -479,21 +479,15 @@ expand_thunk (cgraph_node *node, bool output_asm_thunks,
resdecl,
build_int_cst (TREE_TYPE (resdecl), 0));
}
- else if (!is_gimple_reg_type (restype))
+ else if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl)))
{
- if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl)))
+ restmp = resdecl;
+
+ if (VAR_P (restmp))
{
- restmp = resdecl;
-
- if (VAR_P (restmp))
- {
- add_local_decl (cfun, restmp);
- BLOCK_VARS (DECL_INITIAL (current_function_decl))
- = restmp;
- }
+ add_local_decl (cfun, restmp);
+ BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp;
}
- else
- restmp = create_tmp_var (restype, "retval");
}
else
restmp = create_tmp_reg (restype, "retval");
diff --git a/gcc/testsuite/gcc.dg/bitint-60.c b/gcc/testsuite/gcc.dg/bitint-60.c
new file mode 100644
index 0000000..d1916a0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-60.c
@@ -0,0 +1,20 @@
+/* PR tree-optimization/112941 */
+/* { dg-do compile { target bitint575 } } */
+/* { dg-options "-O2 -std=c23" } */
+
+unsigned _BitInt(495) f1 (signed _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; }
+unsigned _BitInt(495) f2 (unsigned _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; }
+unsigned _BitInt(495) f3 (signed _BitInt(381) x) { _BitInt(539) y = x; return y; }
+unsigned _BitInt(495) f4 (unsigned _BitInt(381) x) { _BitInt(539) y = x; return y; }
+_BitInt(495) f5 (signed _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; }
+_BitInt(495) f6 (unsigned _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; }
+_BitInt(495) f7 (signed _BitInt(381) x) { _BitInt(539) y = x; return y; }
+_BitInt(495) f8 (unsigned _BitInt(381) x) { _BitInt(539) y = x; return y; }
+unsigned _BitInt(495) f9 (signed _BitInt(381) x) { return (unsigned _BitInt(539)) x; }
+unsigned _BitInt(495) f10 (unsigned _BitInt(381) x) { return (unsigned _BitInt(539)) x; }
+unsigned _BitInt(495) f11 (signed _BitInt(381) x) { return (_BitInt(539)) x; }
+unsigned _BitInt(495) f12 (unsigned _BitInt(381) x) { return (_BitInt(539)) x; }
+_BitInt(495) f13 (signed _BitInt(381) x) { return (unsigned _BitInt(539)) x; }
+_BitInt(495) f14 (unsigned _BitInt(381) x) { return (unsigned _BitInt(539)) x; }
+_BitInt(495) f15 (signed _BitInt(381) x) { return (_BitInt(539)) x; }
+_BitInt(495) f16 (unsigned _BitInt(381) x) { return (_BitInt(539)) x; }