| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-fopenmp -O2 -fdump-tree-original -fdump-tree-optimized" } |
| 3 |
! { dg-final { scan-tree-dump-times ".ASSUME \\(i_lower_bound \\(\\) < i\\);" 1 "original" } } |
| 4 |
! { dg-final { scan-tree-dump-times ".ASSUME \\(TARGET_EXPR <D.\[0-9\]+, D.\[0-9\]+ = j_upper_bound \\(\\);" 1 "original" } } |
| 5 |
! { dg-final { scan-tree-dump-times "__builtin_free" 1 "original" } } |
| 6 |
|
| 7 |
! { dg-final { scan-tree-dump-not "i_lower_bound" "optimized" } } |
| 8 |
! { dg-final { scan-tree-dump-not "j_upper_bound" "optimized" } } |
| 9 |
! { dg-final { scan-tree-dump-not "__builtin_free" "optimized" } } |
| 10 |
|
| 11 |
! Note: Currently, the assumption does not help with optimization in either variant. |
| 12 |
|
| 13 |
|
| 14 |
integer function f(i) |
| 15 |
implicit none |
| 16 |
integer, value :: i |
| 17 |
|
| 18 |
!$omp assume holds(i > i_lower_bound ()) |
| 19 |
block |
| 20 |
if (i > 4) then |
| 21 |
f = 42 |
| 22 |
else |
| 23 |
f = -1 |
| 24 |
end if |
| 25 |
end block |
| 26 |
contains |
| 27 |
function i_lower_bound () |
| 28 |
integer :: i_lower_bound |
| 29 |
i_lower_bound = 5 |
| 30 |
end function |
| 31 |
end |
| 32 |
|
| 33 |
integer function g(j) |
| 34 |
implicit none |
| 35 |
integer, value :: j |
| 36 |
|
| 37 |
!$omp assume holds(j < j_upper_bound ()) |
| 38 |
block |
| 39 |
if (j < 10) then |
| 40 |
g = 42 |
| 41 |
else |
| 42 |
g = -1 |
| 43 |
end if |
| 44 |
end block |
| 45 |
contains |
| 46 |
function j_upper_bound () |
| 47 |
integer, allocatable :: j_upper_bound |
| 48 |
j_upper_bound = 10 |
| 49 |
end function |
| 50 |
end |