File: loop-not-in-simplify-form.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (53 lines) | stat: -rw-r--r-- 1,935 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes='loop-mssa(loop-instsimplify,loop-simplifycfg,simple-loop-unswitch)' -S %s | FileCheck %s

; Test case from PR54023. After SimpleLoopUnswitch, one of the loops processed
; by LoopSimplifyCFG will have exit blocks with predecessors outside the loop
; (i.e. it is not in loop-simplify/canonical form).
define i32 @test(i32 %v, i1 %c.1, i1 %c.2) {
; CHECK-LABEL: @test(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br label [[OUTER_HEADER:%.*]]
; CHECK:       outer.header:
; CHECK-NEXT:    br i1 [[C_1:%.*]], label [[OUTER_LATCH:%.*]], label [[INNER_HEADER_PREHEADER:%.*]]
; CHECK:       inner.header.preheader:
; CHECK-NEXT:    br label [[INNER_HEADER:%.*]]
; CHECK:       inner.header:
; CHECK-NEXT:    [[CMP_2:%.*]] = icmp ne i32 [[V:%.*]], 0
; CHECK-NEXT:    br i1 [[CMP_2]], label [[EXIT:%.*]], label [[INNER_LATCH:%.*]]
; CHECK:       inner.latch:
; CHECK-NEXT:    br i1 [[C_2:%.*]], label [[OUTER_LATCH_LOOPEXIT:%.*]], label [[INNER_HEADER]]
; CHECK:       outer.latch.loopexit:
; CHECK-NEXT:    br label [[OUTER_LATCH]]
; CHECK:       outer.latch:
; CHECK-NEXT:    br label [[OUTER_HEADER]]
; CHECK:       exit:
; CHECK-NEXT:    [[RES:%.*]] = phi i32 [ [[V]], [[INNER_HEADER]] ]
; CHECK-NEXT:    br label [[EXIT_SPLIT:%.*]]
; CHECK:       exit.split:
; CHECK-NEXT:    [[RES_SPLIT:%.*]] = phi i32 [ [[RES]], [[EXIT]] ]
; CHECK-NEXT:    ret i32 [[RES_SPLIT]]
;
entry:
  br label %outer.header

outer.header:
  %g.0 = phi i32 [ 10, %outer.latch ], [ 1, %entry ]
  %cmp.1 = icmp eq i32 %g.0, 0
  br i1 %c.1, label %outer.latch, label %inner.header

inner.header:
  %cmp.2 = icmp ne i32 %v, 0
  %or.cond = or i1 %cmp.1, %cmp.2
  br i1 %or.cond, label %exit, label %inner.latch

inner.latch:
  br i1 %c.2, label %outer.latch, label %inner.header

outer.latch:
  br label %outer.header

exit:
  %res = phi i32 [ %v, %inner.header ]
  ret i32 %res
}