TYPE_CANONICAL should specify a canonical type node (equivalent for type
comparison for example during TBAA) for each type declaration.  Failing to do
so causes TBAA pessimizations.

The frontend also does not properly identify equivalent types, which is
a correctness issue.  Consider (reduced from polyhedron protein)

subroutine check (string1, string2)
character (len=1) :: string1, string2
if (string1(1:1) /= string2(1:1)) call abort
end subroutine check
program foo
  character (len=1) :: str, str2
  str(1:1) = ' '
  str2(1:1) = convert_lower_case(str(1:1))
  call check(str, str2)

  contains
          function convert_lower_case (input_string) result (output_string)
          character (len=1) :: input_string, output_string
          output_string = input_string
          end function convert_lower_case

end program

the character array type used in the inline function convert_lower_case is
not connected to the character array type used in the main function.  This
causes the alias-oracle on the alias-improvements branch to consider
str.293[0] and (*str.327_132)[1]{lb: 1 sz: 1} to be non-aliasing even
if str.327_132 is initialized from str.293 via
str.327_132 = (character(kind=1)[1:1] *) &str.293; because the type used
in that conversion is from the inline function and is not equal to that
of std.293.

I believe that boils down to a similar issue as the one-decl for each
function thing.  Either GFortran has to use -fno-strict-aliasing or
needs to properly use canonical types.


-- 
           Summary: Fortran does not set TYPE_CANONICAL properly
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: blocker
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38913

Reply via email to