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]

Re: [Patch, Fortran] PR57785 - Fix folding of dot_product for complex vars


Dear Tobias,

The patch is OK, but you may consider the following remarks:

(1) a comment before

+	      c = gfc_simplify_conjg (a);

reminding the definition of the complex dot product.

(2) I don't like the scan-tree-dump: they are fragile and have a limited
coverage. I'ld prefer a test such as the following

! { dg-do run }
!
! PR fortran/57785
!
! Contributed by Kontantinos Anagnostopoulos
!
! The implicit complex conjugate was missing

if (DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /))   &
   /= SUM (CONJG ((/ (1.0, 2.0), (2.0, 3.0) /))*(/ (1.0, 1.0), (1.0, 4.0) /))) &
   call abort ()
if (ANY (MATMUL ((/ (1.0, 2.0), (2.0, 3.0) /),                                 &
                 RESHAPE ((/ (1.0, 1.0), (1.0, 4.0) /),(/2, 1/))) /=           &
         SUM ((/ (1.0, 2.0), (2.0, 3.0) /)*(/ (1.0, 1.0), (1.0, 4.0) /))))     &
    call abort ()      
end

It checks that DOT_PRODUCT matches its definition (it will catch any attempt
to use CONJG on the second vector instead of the first). It also checks
that MATMUL works as expected.

Thanks for the patch,

Dominique


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