| 1 |
! { dg-do compile } |
| 2 |
! { dg-require-effective-target vect_double } |
| 3 |
! { dg-additional-options "-O3 --param vect-max-peeling-for-alignment=0 -fpredictive-commoning -fdump-tree-pcom-details -std=legacy" } |
| 4 |
! { dg-additional-options "-mprefer-avx128" { target { i?86-*-* x86_64-*-* } } } |
| 5 |
! { dg-additional-options "-mlsx" { target { loongarch*-*-* } } } |
| 6 |
! { dg-additional-options "-mzarch" { target { s390*-*-* } } } |
| 7 |
|
| 8 |
******* RESID COMPUTES THE RESIDUAL: R = V - AU |
| 9 |
* |
| 10 |
* THIS SIMPLE IMPLEMENTATION COSTS 27A + 4M PER RESULT, WHERE |
| 11 |
* A AND M DENOTE THE COSTS OF ADDITION (OR SUBTRACTION) AND |
| 12 |
* MULTIPLICATION, RESPECTIVELY. BY USING SEVERAL TWO-DIMENSIONAL |
| 13 |
* BUFFERS ONE CAN REDUCE THIS COST TO 13A + 4M IN THE GENERAL |
| 14 |
* CASE, OR 10A + 3M WHEN THE COEFFICIENT A(1) IS ZERO. |
| 15 |
* |
| 16 |
SUBROUTINE RESID(U,V,R,N,A) |
| 17 |
INTEGER N |
| 18 |
REAL*8 U(N,N,N),V(N,N,N),R(N,N,N),A(0:3) |
| 19 |
INTEGER I3, I2, I1 |
| 20 |
C |
| 21 |
DO 600 I3=2,N-1 |
| 22 |
DO 600 I2=2,N-1 |
| 23 |
DO 600 I1=2,N-1 |
| 24 |
600 R(I1,I2,I3)=V(I1,I2,I3) |
| 25 |
> -A(0)*( U(I1, I2, I3 ) ) |
| 26 |
> -A(1)*( U(I1-1,I2, I3 ) + U(I1+1,I2, I3 ) |
| 27 |
> + U(I1, I2-1,I3 ) + U(I1, I2+1,I3 ) |
| 28 |
> + U(I1, I2, I3-1) + U(I1, I2, I3+1) ) |
| 29 |
> -A(2)*( U(I1-1,I2-1,I3 ) + U(I1+1,I2-1,I3 ) |
| 30 |
> + U(I1-1,I2+1,I3 ) + U(I1+1,I2+1,I3 ) |
| 31 |
> + U(I1, I2-1,I3-1) + U(I1, I2+1,I3-1) |
| 32 |
> + U(I1, I2-1,I3+1) + U(I1, I2+1,I3+1) |
| 33 |
> + U(I1-1,I2, I3-1) + U(I1-1,I2, I3+1) |
| 34 |
> + U(I1+1,I2, I3-1) + U(I1+1,I2, I3+1) ) |
| 35 |
> -A(3)*( U(I1-1,I2-1,I3-1) + U(I1+1,I2-1,I3-1) |
| 36 |
> + U(I1-1,I2+1,I3-1) + U(I1+1,I2+1,I3-1) |
| 37 |
> + U(I1-1,I2-1,I3+1) + U(I1+1,I2-1,I3+1) |
| 38 |
> + U(I1-1,I2+1,I3+1) + U(I1+1,I2+1,I3+1) ) |
| 39 |
C |
| 40 |
RETURN |
| 41 |
END |
| 42 |
! we want to check that predictive commoning did something on the |
| 43 |
! vectorized loop. If vector factor is 2, the vectorized loop can |
| 44 |
! be predictive commoned, we check if predictive commoning PHI node |
| 45 |
! is created with vector(2) type. |
| 46 |
! { dg-final { scan-tree-dump "Executing predictive commoning without unrolling" "pcom" { xfail vect_variable_length } } } |
| 47 |
! { dg-final { scan-tree-dump "vectp_u.*__lsm.* = PHI <.*vectp_u.*__lsm" "pcom" { xfail vect_variable_length } } } |