Re: [PATCH] PR fortran/84784 - ICEs: verify_gimple failed with -fdefault-integer-8

2022-01-27 Thread Mikael Morin

Le 26/01/2022 à 21:59, Harald Anlauf via Fortran a écrit :

Dear Fortranners,

the use of -fdefault-integer-8 exhibits several cases where
we missed to convert the result of an intrinsic from the
declared to the effective resulting type.

The attached obvious patch fixes this for IMAGE_STATUS,
TEAM_NUMBER, and POPCNT/POPPAR.

OK for mainline if regtesting passes on x86_64-pc-linux-gnu?


This is not a regression, but should be safe.
Can you add a test of POPPAR, similar to that of POPCNT?
OK with that change.


Re: *** SPAM *** [PATCH] PR fortran/104128 - ICE in gfc_widechar_to_char, at fortran/scanner.c:199

2022-01-27 Thread Mikael Morin

Le 23/01/2022 à 22:08, Harald Anlauf via Fortran a écrit :

Dear Fortranners,

conversions between different character kinds using TRANSFER exhibit
inconsistencies that can occur between expr->representation.string
(which is char*) on the one hand, and expr->->value.character.string.

One issue (in target-memory.cc) is easily fixed by simply passing
a conversion flag that was likely forgotten in the past.

The other issue happens in gfc_copy_expr.  Before we unconditionally
converted an existing representation.string to wide char, which is
definitely wrong.  Restricting that code path to default character
kind fixed the problems I could find and produces dumps that looked
fine to me.  Maybe some expert here can find a better fix.

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


This was submitted on time before stage4, so it seems to remain valid.
OK.


Maybe 11-branch?


This is not a regression; I would rather not.

Thanks for the patch.


[PATCH] testsuite: Fix gfortran.dg/ieee/signaling_?.f90 tests for x86 targets

2022-01-27 Thread Uros Bizjak via Fortran
As stated in signaling_?.f90 tests, x86-32 ABI is not suitable to
correctly handle signaling NaNs.  However, XFAIL is not the correct choice
to disable these tests, since various optimizations can generate code
that avoids moves from registers to memory (and back), resulting
in the code that executes correctly, producing spurious XFAIL.
These tests should be disabled on x86-32 using { ! ia32 } dg-directive
which rules out x32 ilp32 ABI, where tests execute without problems.

Please note that check_effective_target_ia32 test tries to compile code that
uses __i386__ target-dependent preprocessor definition, so it is guaranteed
to fail on all non-ia32 targets.

2022-01-27  Uroš Bizjak  

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/signaling_1.f90 (dg-do):
Run only on non-ia32 targets.
* gfortran.dg/ieee/signaling_2.f90 (dg-do): Ditto.
* gfortran.dg/ieee/signaling_3.f90 (dg-do): Ditto.

Tested on x86_64-linux-gnu {,-m32}.

OK for master?

Uros.
diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 
b/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90
index 2b156811c1e..19fee283f54 100644
--- a/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90
+++ b/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail { { i?86-*-* x86_64-*-* } && ilp32 } } }
+! { dg-do run { target { ! ia32 } } }
 ! x87 / x86-32 ABI is unsuitable for signaling NaNs
 !
 ! { dg-additional-sources signaling_1_c.c }
diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 
b/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90
index ee3805272a0..03b04c783eb 100644
--- a/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90
+++ b/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail { { i?86-*-* x86_64-*-* } && ilp32 } } }
+! { dg-do run { target { ! ia32 } } }
 ! x87 / x86-32 ABI is unsuitable for signaling NaNs
 !
 ! { dg-require-effective-target issignaling } */
diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 
b/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90
index 22b36980896..ff2585d2589 100644
--- a/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90
+++ b/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail { { i?86-*-* x86_64-*-* } && ilp32 } } }
+! { dg-do run { target { ! ia32 } } }
 ! x87 / x86-32 ABI is unsuitable for signaling NaNs
 !
 program test


Re: [PATCH] testsuite: Fix gfortran.dg/ieee/signaling_?.f90 tests for x86 targets

2022-01-27 Thread FX via Fortran
Hi Uroš,

> Please note that check_effective_target_ia32 test tries to compile code that
> uses __i386__ target-dependent preprocessor definition, so it is guaranteed
> to fail on all non-ia32 targets.

Thanks, I didn’t know the difference!
OK to push.

FX

Re: FINAL subroutines

2022-01-27 Thread Paul Richard Thomas via Fortran
Hi Salvatore,


My reading of F2018: 7.5.6.3 "When finalization occurs" is that three calls
is correct. (i) Paragraph 1 stipulates that the 'var' expression be
evaluated before the reallocation and intrinsic assignment; (ii)stipulates
that the function result be finalised "the result is finalized after
execution of the innermost
executable construct containing the reference." ; and (iii) Finalisation
occurs on going out of scope.

That is what is implemented in the attached. I am working my way through
the testcase dependencies of PR37336 making sure that finalizat
ion occurs as required by 7.5.6.3 and in the order defined in the previous
section. It will all be done in the next few days.

What will remain is finalization of function results within array
constructors and one or two other corner cases. Following that, the
existing finalization calls will be brought into the framework as the new
calls.

Best regards

Paul


On Thu, 27 Jan 2022 at 07:17, Salvatore Filippone <
filippone.salvat...@gmail.com> wrote:

> One more data point: Cray FTN issues TWO calls to the FINAL.
> Which begs the question: what is the correct number of calls one, two or
> three?
> Salvatore
>
> fsalvato@daint102:/project/prce01/fsalvato/NUMERICAL/PSBLAS/V4/psblas4/test/newstuff>
> ftn --version
> Cray Fortran : Version 11.0.0
> fsalvato@daint102:/project/prce01/fsalvato/NUMERICAL/PSBLAS/V4/psblas4/test/newstuff>
> ftn -o testfinal testfinal.f90
> fsalvato@daint102:/project/prce01/fsalvato/NUMERICAL/PSBLAS/V4/psblas4/test/newstuff>
> ./testfinal
>  Allocating wrapper
>  Calling new_outer_type
>  Assigning outer%test_item
>  Called delete_test_type
>  End of new_outer_type
>  DeAllocating wrapper
>  Called delete_test_type
>
> On Wed, Jan 26, 2022 at 11:59 PM Paul Richard Thomas <
> paul.richard.tho...@gmail.com> wrote:
>
>> Hi Jerry,
>>
>> I am trying to fix the failure of my latest patch with this very test
>> case. Otherwise it fixes most of the remaining dependencies in PR37336.
>>
>> At a pinch, I could submit the earlier patch that Andrew mentions and
>> work from there. However, you will note that it does miss one of the
>> finalizations. This is critical because function results, which should be
>> finalized, are not.
>>
>> I'll keep an eye on the state of the branch. By and large, release occurs
>> 3-4 months after the start of stage 4. I will leave 2 months maximum.
>>
>> Best regards
>>
>> Paul
>>
>>
>> On Wed, 26 Jan 2022 at 21:29, Jerry D via Fortran 
>> wrote:
>>
>>> Is there any reason these patches can not be applied and use this test
>>> as a test case?
>>>
>>> Regards,
>>>
>>> Jerry
>>>
>>> On 1/24/22 8:11 AM, Salvatore Filippone via Fortran wrote:
>>> > Thanks a lot
>>> > (yes, I suspected both gfortran and intel were wrong, precisely
>>> because I
>>> > could see why you'd need two FINAL calls, but not three).
>>> >
>>> > Salvatore
>>> >
>>> > On Mon, Jan 24, 2022 at 4:45 PM Andrew Benson <
>>> aben...@carnegiescience.edu>
>>> > wrote:
>>> >
>>> >> Hi Salvatore,
>>> >>
>>> >> This looks like it's related to some of the missing finalization
>>> >> functionality
>>> >> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37336). Paul has some
>>> >> patches
>>> >> (e.g. https://gcc.gnu.org/pipermail/fortran/2022-January/057415.html)
>>> >> which
>>> >> implement most of the missing functionality. With those patches
>>> >> incorporated
>>> >> your code gives the following output with gfortran:
>>> >>
>>> >> $ ./testfinal
>>> >>   Allocating wrapper
>>> >>   Calling new_outer_type
>>> >>   Assigning outer%test_item
>>> >>   Called delete_test_type
>>> >>   End of new_outer_type
>>> >>   DeAllocating wrapper
>>> >>   Called delete_test_type
>>> >>
>>> >> So there is one more call to the finalizer than you found - I haven't
>>> >> checked
>>> >> carefully but I would guess this is a deallocation of LHS on
>>> assignment.
>>> >>
>>> >> In testing these patches using the Intel compiler we found that it
>>> seems
>>> >> to
>>> >> call the finalization wrapper more than it should, sometimes on
>>> objects
>>> >> that
>>> >> have already been deallocated. Your code, compiled with the Intel
>>> compiler
>>> >> and
>>> >> then run under valgrind shows the following:
>>> >>
>>> >> $ valgrind ./testfinal
>>> >> ==7340== Memcheck, a memory error detector
>>> >> ==7340== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et
>>> al.
>>> >> ==7340== Using Valgrind-3.13.0 and LibVEX; rerun with -h for
>>> copyright info
>>> >> ==7340== Command: ./testfinal
>>> >> ==7340==
>>> >> ==7340== Conditional jump or move depends on uninitialised value(s)
>>> >> ==7340==at 0x493A51: __intel_sse2_strcpy (in
>>> /home/abensonca/Scratch/
>>> >> ifortTests/testfinal)
>>> >> ==7340==by 0x45D70E: for__add_to_lf_table (in
>>> /home/abensonca/Scratch/
>>> >> ifortTests/testfinal)
>>> >> ==7340==by 0x4410CB: for__open_proc (in /home/abensonca/Scratch/
>>> >> ifortTests/testfinal)
>>> >> ==7340==by 0x423A64: for__open_default (in
>>> /h