[gcc r14-6466] SRA: Force gimple operand in an additional corner case (PR 112822)

Martin Jambor jamborm@gcc.gnu.org
Tue Dec 12 20:21:32 GMT 2023


https://gcc.gnu.org/g:cd7d0b4cf789264cd75ab7df5df232dc58061ed7

commit r14-6466-gcd7d0b4cf789264cd75ab7df5df232dc58061ed7
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Dec 12 21:19:21 2023 +0100

    SRA: Force gimple operand in an additional corner case (PR 112822)
    
    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.
    
    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.

Diff:
---
 gcc/tree-sra.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 3bd0c7a9af0..99a1b0a6d17 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -4219,11 +4219,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);
 	    }


More information about the Gcc-cvs mailing list