File: pr56242.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 (51 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (12)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=indvars < %s | FileCheck %s

declare void @use(i1)

define void @test(ptr %arr) {
; CHECK-LABEL: @test(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br label [[LOOP_HEADER:%.*]]
; CHECK:       loop.header:
; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[IV_INC:%.*]], [[LOOP_LATCH:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT:    [[PREV:%.*]] = phi i32 [ [[V:%.*]], [[LOOP_LATCH]] ], [ 0, [[ENTRY]] ]
; CHECK-NEXT:    [[PTR:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 [[IV]]
; CHECK-NEXT:    [[V]] = load i32, ptr [[PTR]], align 4
; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[V]], 0
; CHECK-NEXT:    br i1 [[CMP1]], label [[IF:%.*]], label [[LOOP_LATCH]]
; CHECK:       if:
; CHECK-NEXT:    [[CMP2:%.*]] = icmp slt i32 [[PREV]], 0
; CHECK-NEXT:    call void @use(i1 [[CMP2]])
; CHECK-NEXT:    br label [[LOOP_LATCH]]
; CHECK:       loop.latch:
; CHECK-NEXT:    [[IV_INC]] = add nuw nsw i64 [[IV]], 1
; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i64 [[IV_INC]], 16
; CHECK-NEXT:    br i1 [[CMP]], label [[LOOP_HEADER]], label [[EXIT:%.*]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  br label %loop.header

loop.header:
  %iv = phi i64 [ %iv.inc, %loop.latch ], [ 0, %entry ]
  %prev = phi i32 [ %v, %loop.latch ], [ 0, %entry ]
  %ptr = getelementptr inbounds i32, ptr %arr, i64 %iv
  %v = load i32, ptr %ptr
  %cmp1 = icmp sgt i32 %v, 0
  br i1 %cmp1, label %if, label %loop.latch

if:
  %cmp2 = icmp slt i32 %prev, 0
  call void @use(i1 %cmp2)
  br label %loop.latch

loop.latch:
  %iv.inc = add nuw nsw i64 %iv, 1
  %cmp = icmp ult i64 %iv.inc, 16
  br i1 %cmp, label %loop.header, label %exit

exit:
  ret void
}