https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122988
Bug ID: 122988
Summary: some force_gimple_operand_gsi in tree-tailcall.cc
should be replaced by gimple_build/gimple_convert
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: easyhack, internal-improvement
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
```
if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1))
&& code != POINTER_PLUS_EXPR)
stmt = gimple_build_assign (result, code, acc, op1);
else
{
tree tem;
if (code == POINTER_PLUS_EXPR)
tem = fold_build2 (code, TREE_TYPE (op1), op1, acc);
else
tem = fold_build2 (code, TREE_TYPE (op1),
fold_convert (TREE_TYPE (op1), acc), op1);
tree rhs = fold_convert (ret_type, tem);
rhs = force_gimple_operand_gsi (&gsi, rhs,
false, NULL, true, GSI_SAME_STMT);
stmt = gimple_build_assign (result, rhs);
}
```
And
```
if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1)))
stmt = gimple_build_assign (var, code, acc, op1);
else
{
tree rhs = fold_convert (TREE_TYPE (acc),
fold_build2 (code,
TREE_TYPE (op1),
fold_convert (TREE_TYPE (op1),
acc),
op1));
rhs = force_gimple_operand_gsi (&gsi, rhs,
false, NULL, false,
GSI_CONTINUE_LINKING);
stmt = gimple_build_assign (var, rhs);
}
```
Both of these can be replaced by a few calls to gimple_convert/gimple_build
instead. and even remove the condition here (except for the POINTER_PLUS_EXPR
part).