This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran] Clean-up gfc_trans_where_assign


The following patch is a clean-up to gfc_trans_where_assign resulting
from the recent reorganization of gfc_trans_where_2.  We now always
construct a "ready-to-use" execution mask, so the original code to
traverse a linked list of masks and AND them together can be removed
from gfc_trans_where_assign.  This change was kept separate to simplify
the review of the previous patch.  This'll also please the middle-end
folks, as its one less instance of TREE_CHAIN abuse.  I've not added
a gcc_asert that TREE_CHAIN (mask) is NULL_TREE, as this would preserve
this misuse :-)

The following patch has been tested on x86_64-unknown-linux-gnu with
a top-level bootstrap, including fortran, and regression tested with
a top-level "make -k check" with no new failures.

Ok for mainline?



2006-02-18  Roger Sayle  <roger@eyesopen.com>

	* trans-stmt.c (gfc_trans_where_assign): Remove code to handle
	traversing a linked list of MASKs.  The MASK is now always a
	single element, requiring no ANDing during the assignment.


Index: trans-stmt.c
===================================================================
*** trans-stmt.c	(revision 111245)
--- trans-stmt.c	(working copy)
*************** gfc_trans_where_assign (gfc_expr *expr1,
*** 2740,2746 ****
    tree tmp;
    stmtblock_t block;
    stmtblock_t body;
!   tree index, maskexpr, tmp1;

  #if 0
    /* TODO: handle this special case.
--- 2740,2746 ----
    tree tmp;
    stmtblock_t block;
    stmtblock_t body;
!   tree index, maskexpr;

  #if 0
    /* TODO: handle this special case.
*************** gfc_trans_where_assign (gfc_expr *expr1,
*** 2835,2855 ****
    else
      gfc_conv_expr (&lse, expr1);

!   /* Form the mask expression according to the mask tree list.  */
    index = count1;
!   tmp = mask;
!   if (tmp != NULL)
!     maskexpr = gfc_build_array_ref (tmp, index);
!   else
!     maskexpr = NULL;

-   tmp = TREE_CHAIN (tmp);
-   while (tmp)
-     {
-       tmp1 = gfc_build_array_ref (tmp, index);
-       maskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1), maskexpr, tmp1);
-       tmp = TREE_CHAIN (tmp);
-     }
    /* Use the scalar assignment as is.  */
    tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type);
    tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
--- 2835,2844 ----
    else
      gfc_conv_expr (&lse, expr1);

!   /* Form the mask expression according to the mask.  */
    index = count1;
!   maskexpr = gfc_build_array_ref (mask, index);

    /* Use the scalar assignment as is.  */
    tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type);
    tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
*************** gfc_trans_where_assign (gfc_expr *expr1,
*** 2898,2917 ****

            /* Form the mask expression according to the mask tree list.  */
            index = count2;
!           tmp = mask;
!           if (tmp != NULL)
!             maskexpr = gfc_build_array_ref (tmp, index);
!           else
!             maskexpr = NULL;

-           tmp = TREE_CHAIN (tmp);
-           while (tmp)
-             {
-               tmp1 = gfc_build_array_ref (tmp, index);
-               maskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1),
- 				 maskexpr, tmp1);
-               tmp = TREE_CHAIN (tmp);
-             }
            /* Use the scalar assignment as is.  */
            tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type);
            tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
--- 2887,2894 ----

            /* Form the mask expression according to the mask tree list.  */
            index = count2;
!           maskexpr = gfc_build_array_ref (mask, index);

            /* Use the scalar assignment as is.  */
            tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type);
            tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]