Skip to content

Commit

Permalink
SRA: Force gimple operand in an additional corner case (PR 112822)
Browse files Browse the repository at this point in the history
Hi,

PR 112822 revealed a corner case in load_assign_lhs_subreplacements
where it creates invalid gimple: an assignment where on the LHS there
is a complex variable which however is not a gimple register because
it has partial defs and on the right hand side there is a
VIEW_CONVERT_EXPR.  This patch invokes force_gimple_operand_gsi on
such statements (like it already does when both sides of a generated
assignment have partial definitions.

I've made sure the patch passes bootstrap and testsuite on x86_64-linux,
the bug reporter was kind enough to also check the same on an
powerpc64le-linux (see bugzilla comment #8).

The testcase has reasonable size but it is specific to ppc64le and its
altivec vectors.  My plan is to ask the bug reporter to massage it into
a target specific testcase in bugzilla.  Alternatively I can try to
craft a testcase from scratch but that will take time.

Despite the above, is the patch OK for master?

Thanks,

Martin

gcc/ChangeLog:

2023-12-12  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/112822
	* tree-sra.cc (load_assign_lhs_subreplacements): Invoke
	force_gimple_operand_gsi also when LHS has partial stores and RHS is a
	VIEW_CONVERT_EXPR.
  • Loading branch information
jamborm authored and ouuleilei-bot committed Dec 13, 2023
1 parent c2d62cd commit de0d8cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gcc/tree-sra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3995,11 +3995,15 @@ load_assign_lhs_subreplacements (struct access *lacc,
if (racc && racc->grp_to_be_replaced)
{
rhs = get_access_replacement (racc);
bool vce = false;
if (!useless_type_conversion_p (lacc->type, racc->type))
rhs = fold_build1_loc (sad->loc, VIEW_CONVERT_EXPR,
lacc->type, rhs);
{
rhs = fold_build1_loc (sad->loc, VIEW_CONVERT_EXPR,
lacc->type, rhs);
vce = true;
}

if (racc->grp_partial_lhs && lacc->grp_partial_lhs)
if (lacc->grp_partial_lhs && (vce || racc->grp_partial_lhs))
rhs = force_gimple_operand_gsi (&sad->old_gsi, rhs, true,
NULL_TREE, true, GSI_SAME_STMT);
}
Expand Down

0 comments on commit de0d8cd

Please sign in to comment.