File: pr102597.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (44 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download | duplicates (2)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=indvars < %s | FileCheck %s

; The %tobool condition should not be optimized away.
define void @test() {
; CHECK-LABEL: define void @test() {
; CHECK-NEXT:  [[ENTRY:.*]]:
; CHECK-NEXT:    br label %[[LOOP:.*]]
; CHECK:       [[LOOP]]:
; CHECK-NEXT:    [[IV:%.*]] = phi i128 [ 3, %[[ENTRY]] ], [ [[IV_DEC:%.*]], %[[LOOP_LATCH:.*]] ]
; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp ne i128 [[IV]], 0
; CHECK-NEXT:    br i1 [[TOBOOL]], label %[[LOOP_LATCH]], label %[[IF:.*]]
; CHECK:       [[IF]]:
; CHECK-NEXT:    call void @foo()
; CHECK-NEXT:    br label %[[LOOP_LATCH]]
; CHECK:       [[LOOP_LATCH]]:
; CHECK-NEXT:    [[IV_DEC]] = add nsw i128 [[IV]], -1
; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i128 [[IV]], 0
; CHECK-NEXT:    br i1 [[CMP]], label %[[LOOP]], label %[[EXIT:.*]]
; CHECK:       [[EXIT]]:
; CHECK-NEXT:    ret void
;
entry:
  br label %loop

loop:
  %iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]
  %tobool = icmp ne i128 %iv, 0
  br i1 %tobool, label %loop.latch, label %if

if:
  call void @foo()
  br label %loop.latch

loop.latch:
  %iv.dec = add nsw i128 %iv, -1
  %cmp = icmp sgt i128 %iv, 0
  br i1 %cmp, label %loop, label %exit

exit:
  ret void
}

declare void @foo()