* cfgloopmanip.c (duplicate_loop_to_header_edge): Cleanup profile
[official-gcc.git] / gcc / testsuite / gfortran.dg / power_3.f90
blob001ea7347a0ad8d7257a3e1cac72fc995f399527
1 ! { dg-do run }
2 ! { dg-options "-ffrontend-optimize -fdump-tree-original" }
3 ! PR 57071 - Check that (-1)**k is transformed into 1-2*iand(k,1).
4 program main
5 implicit none
6 integer, parameter :: n = 3
7 integer(kind=8), dimension(-n:n) :: a, b
8 integer, dimension(-n:n) :: c, d, e
9 integer :: m
10 integer :: i, v
11 integer (kind=2) :: i2
13 m = n
14 v = -1
15 ! Test in scalar expressions
16 do i=-n,n
17 if (v**i /= (-1)**i) call abort
18 end do
20 ! Test in array constructors
21 a(-m:m) = [ ((-1)**i, i= -m, m) ]
22 b(-m:m) = [ ( v**i, i= -m, m) ]
23 if (any(a .ne. b)) call abort
25 ! Test in array expressions
26 c = [ ( i, i = -n , n ) ]
27 d = (-1)**c
28 e = v**c
29 if (any(d .ne. e)) call abort
31 ! Test in different kind expressions
32 do i2=-n,n
33 if (v**i2 /= (-1)**i2) call abort
34 end do
36 end program main
37 ! { dg-final { scan-tree-dump-times "_gfortran_pow_i4_i4" 4 "original" } }