Skip to content

Commit 8ead6c5

Browse files
committed
Add testcase from #77329
1 parent a1b59bf commit 8ead6c5

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
! RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s
2+
3+
subroutine sub(imax, jmax, x, y)
4+
integer, intent(in) :: imax, jmax
5+
real, intent(in), dimension(1:imax, 1:jmax) :: x, y
6+
7+
integer :: i, j, ii
8+
9+
! collapse(2) is needed to reproduce the issue
10+
!$omp parallel do collapse(2)
11+
do j = 1, jmax
12+
do i = 1, imax
13+
do ii = 1, imax ! note that this loop is not collapsed
14+
if (x(i,j) < y(ii,j)) then
15+
! exit needed to force unstructured control flow
16+
exit
17+
endif
18+
enddo
19+
enddo
20+
enddo
21+
end subroutine sub
22+
23+
! this is testing that we don't crash generating code for this: in particular
24+
! that all blocks are terminated
25+
26+
! CHECK-LABEL: func.func @_QPsub(
27+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "imax"},
28+
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "jmax"},
29+
! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<!fir.array<?x?xf32>> {fir.bindc_name = "x"},
30+
! CHECK-SAME: %[[VAL_3:.*]]: !fir.ref<!fir.array<?x?xf32>> {fir.bindc_name = "y"}) {
31+
! [...]
32+
! CHECK: omp.wsloop for (%[[VAL_53:.*]], %[[VAL_54:.*]]) : i32 = ({{.*}}) to ({{.*}}) inclusive step ({{.*}}) {
33+
! [...]
34+
! CHECK: cf.br ^bb1
35+
! CHECK: ^bb1:
36+
! CHECK: cf.br ^bb2
37+
! CHECK: ^bb2:
38+
! [...]
39+
! CHECK: cf.br ^bb3
40+
! CHECK: ^bb3:
41+
! [...]
42+
! CHECK: %[[VAL_63:.*]] = arith.cmpi sgt, %{{.*}}, %{{.*}} : i32
43+
! CHECK: cf.cond_br %[[VAL_63]], ^bb4, ^bb7
44+
! CHECK: ^bb4:
45+
! [...]
46+
! CHECK: %[[VAL_76:.*]] = arith.cmpf olt, %{{.*}}, %{{.*}} fastmath<contract> : f32
47+
! CHECK: cf.cond_br %[[VAL_76]], ^bb5, ^bb6
48+
! CHECK: ^bb5:
49+
! CHECK: cf.br ^bb7
50+
! CHECK: ^bb6:
51+
! [...]
52+
! CHECK: cf.br ^bb3
53+
! CHECK: ^bb7:
54+
! CHECK: omp.yield
55+
! CHECK: }
56+
! CHECK: omp.terminator
57+
! CHECK: }
58+
! CHECK: cf.br ^bb1
59+
! CHECK: ^bb1:
60+
! CHECK: return
61+
! CHECK: }

0 commit comments

Comments
 (0)