https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81698
Bug ID: 81698 Summary: expand_omp_sections generates unusual switch Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- I. A switch has the default label as its first label: ... switch (cD.2303) <default: <L2> [INV] [count: INV], case 1: <L1> [INV] [count: INV], case 2: <L0> [INV] [count: INV]> ... And because build_cfg makes edges iterating over the switch labels, the default edge will have index '0'. In expand_case, we seem to be relying on this (it seems fragile to me though): ... edge default_edge = EDGE_SUCC (bb, 0); ... II. The switch resulting from expand_omp_sections does not have the default edge as first edge (in fact, it's the last): ... switch (.section.0D.1925) <default: <L6> [INV] [count: INV], case 0: <L0> [INV] [count: INV], case 1: <L7> [INV] [count: INV], case 2: <L8> [INV] [count: INV], case 3: <L9> [INV] [count: INV], case 4: <L10> [INV] [count: INV], case 5: <L11> [INV] [count: INV]> ;; succ: 8 ;; 7 ;; 6 ;; 5 ;; 4 ;; 11 ;; 9 ;; basic block 8, loop depth 1, freq 0, maybe hot ;; prev block 7, next block 9, flags: (NEW, REACHABLE) ;; pred: 3 <L11>: # USE = anything # CLB = anything barD.1917 (5); goto <bb 10>; [INV] [count: INV] ;; succ: 10 (FALLTHRU) ;; basic block 9, loop depth 0, freq 0, maybe hot ;; prev block 8, next block 10, flags: (NEW) ;; pred: 3 <L6>: # USE = anything # CLB = anything __builtin_trapD.1087 (); ;; succ: ... III. So we need either to: - fix expand_omp_sections to emit a normal-form switch, or - stop relying on the first edge being the default edge.