aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-intrinsic.cc
diff options
context:
space:
mode:
authorMikael Morin <mikael@gcc.gnu.org>2024-11-19 21:17:37 +0100
committerMikael Morin <mikael@gcc.gnu.org>2024-11-19 21:17:37 +0100
commit83da0a00d1a67b6999cb4e1912f26a334bab1b66 (patch)
treea7d65fcd190e2435f33a5a01ac4679d38f92e182 /gcc/fortran/trans-intrinsic.cc
parent8663fc1c2826c86455e51e58203cb95b2b1407e3 (diff)
downloadgcc-83da0a00d1a67b6999cb4e1912f26a334bab1b66.zip
gcc-83da0a00d1a67b6999cb4e1912f26a334bab1b66.tar.gz
gcc-83da0a00d1a67b6999cb4e1912f26a334bab1b66.tar.bz2
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.
Diffstat (limited to 'gcc/fortran/trans-intrinsic.cc')
-rw-r--r--gcc/fortran/trans-intrinsic.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 6a47c23..4011b9e 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -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;