Le 17/09/2022 à 21:33, Mikael Morin a écrit :
The testcase from the patch was not specifically checking lack of
side-effect clobbers, so I have double-checked with the following
testcase, which should lift your concerns.
The dump matches didn’t fail as expected with patch 2/10 reversed.
This testcase should be better.
! { dg-do run }
! { dg-additional-options "-fno-inline -fno-ipa-modref -fdump-tree-optimized -fdump-tree-original" }
!
! PR fortran/41453
! Check that the INTENT(OUT) attribute causes one clobber to be emitted
! for the array element passed as argument in the *.original dump, and the
! associated initialization constant to be optimized away in the *.optimized
! dump, whereas the other initialization constants are not optimized away.
module x
implicit none
contains
subroutine foo(a)
integer, intent(out) :: a
a = 42
end subroutine foo
end module x
program main
use x
implicit none
integer :: ac(3)
ac(1) = 123
ac(2) = 456
ac(3) = 789
call foo(ac(2))
if (any(ac /= [123, 42, 789])) stop 1
end program main
! { dg-final { scan-tree-dump-times "CLOBBER" 1 "original" } }
! { dg-final { scan-tree-dump "ac\\\[1\\\] = {CLOBBER};" "original" } }
! { dg-final { scan-tree-dump-times "123" 2 "original" } }
! { dg-final { scan-tree-dump-times "123" 2 "optimized" } }
! { dg-final { scan-tree-dump-times "456" 1 "original" } }
! { dg-final { scan-tree-dump-times "456" 0 "optimized" { target __OPTIMIZE__ } } }
! { dg-final { scan-tree-dump-times "789" 2 "original" } }
! { dg-final { scan-tree-dump-times "789" 2 "optimized" } }