Re: Coarray on trunk

2025-07-01 Thread Andre Vehreschild

Hi Jerry,

thanks for the report. I am positive that I merged the correct patch, but 
I'll check tomorrow when it's a little bit cooler. At the moment it's so 
incredibly hot, one can't concentrate.


Sorry for the mess,
Andre
Andre Vehreschild * ve...@gmx.de
Am 1. Juli 2025 19:33:41 schrieb Jerry D :


Hi all,

With latest trunk this morning after Andre's commits I am still getting 
failures

with Toon's random_weather.f90.

Was there another patch I missed?

Jerry

$ gfc -fcoarray=single random-weather.f90
f951: internal compiler error: in gfc_ref_this_image, at fortran/expr.cc:5948
0x21dce1f internal_error(char const*, ...)
../../trunk/gcc/diagnostic-global-context.cc:517
0x647e93 fancy_abort(char const*, int, char const*)
../../trunk/gcc/diagnostic.cc:1810
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5948
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5944
0x730068 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4831
0x730068 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834
0x72e449 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4356
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x734503 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834




Re: Coarray on trunk

2025-07-01 Thread Andre Vehreschild

Hi Jerry,

I just had a look into pr120843 and I have successfully merged the old 
version of the patch. This what you are hitting now. I am very sorry.


The new 'else if' near the coarray error message should be something like:

else if (!op1.ref || !gfc_ref_this_image (op1.ref) ||

and the same for op2. I will fix it tomorrow. Sorry again for all the bother.

- Andre
Andre Vehreschild  * ve...@gmx.de
Am 1. Juli 2025 19:33:41 schrieb Jerry D :


Hi all,

With latest trunk this morning after Andre's commits I am still getting 
failures

with Toon's random_weather.f90.

Was there another patch I missed?

Jerry

$ gfc -fcoarray=single random-weather.f90
f951: internal compiler error: in gfc_ref_this_image, at fortran/expr.cc:5948
0x21dce1f internal_error(char const*, ...)
../../trunk/gcc/diagnostic-global-context.cc:517
0x647e93 fancy_abort(char const*, int, char const*)
../../trunk/gcc/diagnostic.cc:1810
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5948
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5944
0x730068 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4831
0x730068 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834
0x72e449 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4356
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x734503 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834




[PATCH] Fortran: fix minor issues with coarrays

2025-07-01 Thread Harald Anlauf

Dear all,

the attached patch fixes the following minor issues found by running
f951 under valgrind for the just added new testcases coindexed_6.f90
and coindexed_7.f90:

- minor front-end memleaks with non-freed strings and lost GMP variables
 (these are simple and obvious fixes)

- an inconsistency between pure/elemental functions being either
 non-intrinsic or intrinsic.  Checking for the latter was likely missed
 from the beginning.

No new testcase.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald

From 1630d24e3e1d3ab5ae6450da0da555f4eed6339c Mon Sep 17 00:00:00 2001
From: Harald Anlauf 
Date: Tue, 1 Jul 2025 21:41:53 +0200
Subject: [PATCH] Fortran: fix minor issues with coarrays

gcc/fortran/ChangeLog:

	* coarray.cc (check_add_new_component): Treat pure and elemental
	intrinsic functions the same as non-intrinsic ones.
	(create_caf_add_data_parameter_type): Fix front-end memleaks.
	* trans-intrinsic.cc (conv_caf_func_index): Likewise.
---
 gcc/fortran/coarray.cc | 7 +--
 gcc/fortran/trans-intrinsic.cc | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/coarray.cc b/gcc/fortran/coarray.cc
index 6914697c78b..ef8fd4e42d0 100644
--- a/gcc/fortran/coarray.cc
+++ b/gcc/fortran/coarray.cc
@@ -697,7 +697,10 @@ check_add_new_component (gfc_symbol *type, gfc_expr *e, gfc_symbol *add_data)
 	  break;
 	case EXPR_FUNCTION:
 	  if (!e->symtree->n.sym->attr.pure
-	  && !e->symtree->n.sym->attr.elemental)
+	  && !e->symtree->n.sym->attr.elemental
+	  && !(e->value.function.isym
+		   && (e->value.function.isym->pure
+		   || e->value.function.isym->elemental)))
 	/* Treat non-pure/non-elemental functions.  */
 	check_add_new_comp_handle_array (e, type, add_data);
 	  else
@@ -743,7 +746,6 @@ create_caf_add_data_parameter_type (gfc_expr *expr, gfc_namespace *ns,
   add_data->as->lower[0]
 = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind,
 			 &expr->where);
-  mpz_init (add_data->as->lower[0]->value.integer);
   mpz_set_si (add_data->as->lower[0]->value.integer, 1);
 
   for (gfc_ref *ref = expr->ref; ref; ref = ref->next)
@@ -763,6 +765,7 @@ create_caf_add_data_parameter_type (gfc_expr *expr, gfc_namespace *ns,
   type->declared_at = expr->where;
   gfc_set_sym_referenced (type);
   gfc_commit_symbol (type);
+  free (name);
   return type;
 }
 
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index fce5ee28de8..f1bfd3eee51 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -1052,7 +1052,7 @@ conv_caf_func_index (stmtblock_t *block, gfc_namespace *ns, const char *pat,
   index_st->n.sym->value
 = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind,
 			 &gfc_current_locus);
-  mpz_init_set_si (index_st->n.sym->value->value.integer, -1);
+  mpz_set_si (index_st->n.sym->value->value.integer, -1);
   index_st->n.sym->ts.type = BT_INTEGER;
   index_st->n.sym->ts.kind = gfc_default_integer_kind;
   gfc_set_sym_referenced (index_st->n.sym);
-- 
2.43.0



Re: [PATCH] Fortran: fix minor issues with coarrays

2025-07-01 Thread Jerry D

On 7/1/25 12:51 PM, Harald Anlauf wrote:

Dear all,

the attached patch fixes the following minor issues found by running
f951 under valgrind for the just added new testcases coindexed_6.f90
and coindexed_7.f90:

- minor front-end memleaks with non-freed strings and lost GMP variables
  (these are simple and obvious fixes)

- an inconsistency between pure/elemental functions being either
  non-intrinsic or intrinsic.  Checking for the latter was likely missed
  from the beginning.

No new testcase.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald



Yes, OK, straight-forward.

Thanks,

Jerry


Coarray on trunk

2025-07-01 Thread Jerry D

Hi all,

With latest trunk this morning after Andre's commits I am still getting failures 
with Toon's random_weather.f90.


Was there another patch I missed?

Jerry

$ gfc -fcoarray=single random-weather.f90
f951: internal compiler error: in gfc_ref_this_image, at fortran/expr.cc:5948
0x21dce1f internal_error(char const*, ...)
../../trunk/gcc/diagnostic-global-context.cc:517
0x647e93 fancy_abort(char const*, int, char const*)
../../trunk/gcc/diagnostic.cc:1810
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5948
0x40369d gfc_ref_this_image(gfc_ref*)
../../trunk/gcc/fortran/expr.cc:5944
0x730068 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4831
0x730068 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834
0x72e449 resolve_operator
../../trunk/gcc/fortran/resolve.cc:4356
0x72e449 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7860
0x734503 gfc_resolve_expr(gfc_expr*)
../../trunk/gcc/fortran/resolve.cc:7834



Re: [PATCH] Fortran: fix minor issues with coarrays

2025-07-01 Thread Harald Anlauf

Am 01.07.25 um 21:54 schrieb Jerry D:

On 7/1/25 12:51 PM, Harald Anlauf wrote:

Dear all,

the attached patch fixes the following minor issues found by running
f951 under valgrind for the just added new testcases coindexed_6.f90
and coindexed_7.f90:

- minor front-end memleaks with non-freed strings and lost GMP variables
  (these are simple and obvious fixes)

- an inconsistency between pure/elemental functions being either
  non-intrinsic or intrinsic.  Checking for the latter was likely missed
  from the beginning.

No new testcase.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald



Yes, OK, straight-forward.

Thanks,

Jerry



Thanks, Jerry!

Pushed as r16-1903-gfc029f5d34168c.

Hope it doesn't interfere with Andre's work...

Harald



Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-07-01 Thread Jakub Jelinek
On Sat, Jun 28, 2025 at 02:19:59AM +, Yuao Ma wrote:
> > signbit is documented to be a macro, so please don't declare
> > int signbit (double);
> > function in the testcase and instead of signbit use __builtin_signbit.
> 
> This is indeed my negligence. Done.
> 
> If everything looks good, could you please help me merge this patch? Thank 
> you!

Committed in r16-1839.

I don't have mpfr 4.2.0 yet, so didn't test myself with it.

Jakub



Re: [Fortran, Patch, PR120843, v2] Fix reject valid, because of inconformable coranks

2025-07-01 Thread Andre Vehreschild
Hi Harald,

thanks for the review. Committed as gcc-16-1885-g1b0930e9046.

Will backport to gcc-15 in about a week.

Thanks again.

Regards,
Andre

On Mon, 30 Jun 2025 22:31:08 +0200
Harald Anlauf  wrote:

> Am 30.06.25 um 15:25 schrieb Andre Vehreschild:
> > Hi all,
> > 
> > here now the version of the patch that seems to be more complete.
> > 
> > Regtests ok on x86_64-pc-linux-gnu / F41. Ok for mainline and later
> > backport to gcc-15?  
> 
> This looks good to me.  OK for both.
> 
> Thanks for the patch!
> 
> Harald
> 
> > Regards,
> > Andre
> > 
> > On Fri, 27 Jun 2025 15:44:20 +0200
> > Andre Vehreschild  wrote:
> >   
> >> I take this patch back. It seems to be incomplete.
> >>
> >> - Andre
> >>
> >> On Fri, 27 Jun 2025 14:45:36 +0200
> >> Andre Vehreschild  wrote:
> >>  
> >>> Hi all,
> >>>
> >>> this patch fixes a reject valid when the coranks of two operands do not
> >>> match and no coindex is given. I.e. when only an implicit this_image
> >>> co-ref is used.
> >>>
> >>> Regtests ok on x86_64-pc-linux-gnu / F41. Ok for mainline?
> >>>
> >>> Regards,
> >>>   Andre  
> >>
> >>  
> > 
> >   
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 


Re: [Fortran, Patch, PR120847 (was: PR120846), v1] Fix ICE when a function is called more than once in a coarray expression.

2025-07-01 Thread Andre Vehreschild
Hi Harald,

thanks for review. Committed as gcc-16-1891-gee31ab9b195.

Sorry for the typo in the email title. I should have proof read that before
sending.

I will set me a reminder to backport in a week to gcc-15.

Thanks again,
Andre

On Mon, 30 Jun 2025 21:44:03 +0200
Harald Anlauf  wrote:

> Am 30.06.25 um 15:29 schrieb Andre Vehreschild:
> > Hi all,
> > 
> > attached patch fixes an ICE when in an expression with a coindex a function
> > was used more than once. E.g. coarray(mod( something ), mod( something else
> > ))[i] ICE'd because a component for aliasing the second mod() could not be
> > created.
> > 
> > Regtests ok on x86_64-pc-linux-gnu / F41. Ok for mainline and gcc-15 later
> > on?
> > 
> > Regards,
> > Andre  
> 
> Yes, this is OK for both.
> 
> (Be careful about PR numbers, they are correct in the patch;
> the subject is off-by-one.)
> 
> Thanks for the patch!
> 
> Harald
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de