mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-11-24 19:05:28 +08:00
fortran: Check MASK directly instead of its scalarization chain
Update the conditions used by the inline MINLOC/MAXLOC code generation function to check directly the properties of MASK instead of the variable holding its scalarization chain. The inline implementation of MINLOC/MAXLOC in gfc_conv_intrinsic_minmaxloc uses several conditions checking the presence of a scalarization chain for MASK, which means that the argument is present and non-scalar. The next patch will allow inlining MINLOC/MAXLOC with DIM and MASK, and in that case the scalarization chain for MASK is initialized elsewhere, so the variable usually holding it in the function is not used, and the conditions won't work in that case. This change updates the conditions to check directly the properties of MASK so that they work even if the scalarization chain variable is not used. gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Use conditionals based on the MASK expression rather than on its scalarization chains.
This commit is contained in:
parent
8663fc1c28
commit
83da0a00d1
@ -5747,7 +5747,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
|
||||
gcc_assert (reduction_dimensions == ploop->dimen);
|
||||
|
||||
if (nonempty == NULL && maskss == NULL)
|
||||
if (nonempty == NULL && !(maskexpr && maskexpr->rank > 0))
|
||||
{
|
||||
nonempty = logical_true_node;
|
||||
|
||||
@ -5817,7 +5817,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
gfc_start_scalarized_body (ploop, &body);
|
||||
|
||||
/* If we have a mask, only check this element if the mask is set. */
|
||||
if (maskss)
|
||||
if (maskexpr && maskexpr->rank > 0)
|
||||
{
|
||||
gcc_assert (!nested_loop);
|
||||
gfc_init_se (&maskse, NULL);
|
||||
@ -5922,7 +5922,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
}
|
||||
gfc_add_expr_to_block (&block, ifbody);
|
||||
|
||||
if (maskss)
|
||||
if (maskexpr && maskexpr->rank > 0)
|
||||
{
|
||||
/* We enclose the above in if (mask) {...}. If the mask is an
|
||||
optional argument, generate IF (.NOT. PRESENT(MASK)
|
||||
@ -5973,7 +5973,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
gfc_add_expr_to_block (outer_block, build1_v (LABEL_EXPR, lab1));
|
||||
|
||||
/* If we have a mask, only check this element if the mask is set. */
|
||||
if (maskss)
|
||||
if (maskexpr && maskexpr->rank > 0)
|
||||
{
|
||||
gfc_init_se (&maskse, NULL);
|
||||
gfc_copy_loopinfo_to_se (&maskse, &loop);
|
||||
@ -6039,7 +6039,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
|
||||
gfc_add_expr_to_block (&block, tmp);
|
||||
|
||||
if (maskss)
|
||||
if (maskexpr && maskexpr->rank > 0)
|
||||
{
|
||||
/* We enclose the above in if (mask) {...}. If the mask is
|
||||
an optional argument, generate IF (.NOT. PRESENT(MASK)
|
||||
@ -6064,7 +6064,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
|
||||
gfc_add_expr_to_block (&loop.pre, build1_v (LABEL_EXPR, lab2));
|
||||
|
||||
/* For a scalar mask, enclose the loop in an if statement. */
|
||||
if (maskexpr && maskss == NULL)
|
||||
if (maskexpr && maskexpr->rank == 0)
|
||||
{
|
||||
tree ifmask;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user