File: pr30806-phi-scev.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (65 lines) | stat: -rw-r--r-- 2,102 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
; RUN: opt -S -passes=indvars < %s | FileCheck %s

; Produced from the test-case:
;
; extern void foo(char *, unsigned , unsigned *);
; extern void bar(int *, long);
; extern char *processBuf(char *);
;
; extern unsigned theSize;
;
; void foo(char *buf, unsigned denominator, unsigned *flag) {
;   int incr = (int) (theSize / denominator);
;   int inx = 0;
;   while (*flag) {
;     int itmp = inx + incr;
;     int i = (int) theSize;
;     bar(&i, (long) itmp);
;     buf = processBuf(buf);
;     inx = itmp;
;   }
; }

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

@theSize = external local_unnamed_addr global i32, align 4

define void @foo(ptr %buf, i32 %denominator, ptr %flag) local_unnamed_addr {
entry:
  %i = alloca i32, align 4
  %0 = load i32, ptr @theSize, align 4
  %div = udiv i32 %0, %denominator
  %1 = load i32, ptr %flag, align 4
  %tobool5 = icmp eq i32 %1, 0
  br i1 %tobool5, label %while.end, label %while.body.lr.ph

while.body.lr.ph:                                 ; preds = %entry
  br label %while.body

while.body:                                       ; preds = %while.body.lr.ph, %while.body
; Check that there are two PHIs followed by a 'sext' in the same block, and that
; the test does not crash.
; CHECK:        phi
; CHECK-NEXT:   phi
; CHECK-NEXT:   sext
  %buf.addr.07 = phi ptr [ %buf, %while.body.lr.ph ], [ %call, %while.body ]
  %inx.06 = phi i32 [ 0, %while.body.lr.ph ], [ %add, %while.body ]
  %add = add nsw i32 %inx.06, %div
  %2 = load i32, ptr @theSize, align 4
  store i32 %2, ptr %i, align 4
  %conv = sext i32 %add to i64
  call void @bar(ptr nonnull %i, i64 %conv)
  %call = call ptr @processBuf(ptr %buf.addr.07)
  %3 = load i32, ptr %flag, align 4
  %tobool = icmp eq i32 %3, 0
  br i1 %tobool, label %while.end.loopexit, label %while.body

while.end.loopexit:                               ; preds = %while.body
  br label %while.end

while.end:                                        ; preds = %while.end.loopexit, %entry
  ret void
}

declare void @bar(ptr, i64) local_unnamed_addr
declare ptr @processBuf(ptr) local_unnamed_addr