ada: Avoid doing unnecessary work in elaborate_expression_2
This prevents the expression from being tweaked by the match.pd machinery in the process, which can damage the readability of the -gnatR3 output. gcc/ada/ChangeLog: * gcc-interface/decl.cc (elaborate_expression_2): Do not divide and multiply back if the alignment factor is already explicit.
This commit is contained in:
parent
29112f5e1b
commit
01413da3b0
1 changed files with 24 additions and 9 deletions
|
@ -7355,15 +7355,30 @@ static tree
|
|||
elaborate_expression_2 (tree gnu_expr, Entity_Id gnat_entity, const char *s,
|
||||
bool definition, bool need_for_debug, unsigned int align)
|
||||
{
|
||||
tree unit_align = size_int (align / BITS_PER_UNIT);
|
||||
return
|
||||
size_binop (MULT_EXPR,
|
||||
elaborate_expression_1 (size_binop (EXACT_DIV_EXPR,
|
||||
gnu_expr,
|
||||
unit_align),
|
||||
gnat_entity, s, definition,
|
||||
need_for_debug),
|
||||
unit_align);
|
||||
/* Nothing more to do if the factor is already explicit in the tree. */
|
||||
if (TREE_CODE (gnu_expr) == MULT_EXPR
|
||||
&& TREE_CONSTANT (TREE_OPERAND (gnu_expr, 1))
|
||||
&& value_factor_p (TREE_OPERAND (gnu_expr, 1), align / BITS_PER_UNIT))
|
||||
return
|
||||
size_binop (MULT_EXPR,
|
||||
elaborate_expression_1 (TREE_OPERAND (gnu_expr, 0),
|
||||
gnat_entity, s, definition,
|
||||
need_for_debug),
|
||||
TREE_OPERAND (gnu_expr, 1));
|
||||
|
||||
/* Otherwise divide by the factor, elaborate the result and multiply back. */
|
||||
else
|
||||
{
|
||||
tree unit_align = size_int (align / BITS_PER_UNIT);
|
||||
return
|
||||
size_binop (MULT_EXPR,
|
||||
elaborate_expression_1 (size_binop (EXACT_DIV_EXPR,
|
||||
gnu_expr,
|
||||
unit_align),
|
||||
gnat_entity, s, definition,
|
||||
need_for_debug),
|
||||
unit_align);
|
||||
}
|
||||
}
|
||||
|
||||
/* Structure to hold internal data for elaborate_reference. */
|
||||
|
|
Loading…
Add table
Reference in a new issue