]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/LoopVectorize/pr28541.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / LoopVectorize / pr28541.ll
1 ; RUN: opt -loop-vectorize -pass-remarks=loop-vectorize -S < %s 2>&1 | FileCheck %s
2
3 ; FIXME: Check for -pass-remarks-missed and -pass-remarks-analysis output when
4 ; addAcyclicInnerLoop emits analysis.
5
6 ; Check that opt does not crash on such input:
7 ;
8 ; a, b, c;
9 ; fn1() {
10 ;   while (b--) {
11 ;     c = a;
12 ;     switch (a & 3)
13 ;     case 0:
14 ;       do
15 ;     case 3:
16 ;     case 2:
17 ;     case 1:
18 ;         ;
19 ;         while (--c)
20 ;           ;
21 ;   }
22 ; }
23
24 @b = common global i32 0, align 4
25 @a = common global i32 0, align 4
26 @c = common global i32 0, align 4
27
28 ; CHECK-NOT: vectorized loop
29 ; CHECK-LABEL: fn1
30
31 define i32 @fn1() {
32 entry:
33   %tmp2 = load i32, i32* @b, align 4
34   %dec3 = add nsw i32 %tmp2, -1
35   store i32 %dec3, i32* @b, align 4
36   %tobool4 = icmp eq i32 %tmp2, 0
37   br i1 %tobool4, label %while.end, label %while.body.lr.ph
38
39 while.body.lr.ph:                                 ; preds = %entry
40   %tmp1 = load i32, i32* @a, align 4
41   %and = and i32 %tmp1, 3
42   %switch = icmp eq i32 %and, 0
43   br label %while.body
44
45 while.cond:                                       ; preds = %do.cond
46   %dec = add nsw i32 %dec7, -1
47   %tobool = icmp eq i32 %dec7, 0
48   br i1 %tobool, label %while.cond.while.end_crit_edge, label %while.body
49
50 while.body:                                       ; preds = %while.body.lr.ph, %while.cond
51   %dec7 = phi i32 [ %dec3, %while.body.lr.ph ], [ %dec, %while.cond ]
52   br i1 %switch, label %do.body, label %do.cond
53
54 do.body:                                          ; preds = %do.cond, %while.body
55   %dec25 = phi i32 [ %dec2, %do.cond ], [ %tmp1, %while.body ]
56   br label %do.cond
57
58 do.cond:                                          ; preds = %do.body, %while.body
59   %dec26 = phi i32 [ %dec25, %do.body ], [ %tmp1, %while.body ]
60   %dec2 = add nsw i32 %dec26, -1
61   %tobool3 = icmp eq i32 %dec2, 0
62   br i1 %tobool3, label %while.cond, label %do.body
63
64 while.cond.while.end_crit_edge:                   ; preds = %while.cond
65   store i32 0, i32* @c, align 4
66   store i32 -1, i32* @b, align 4
67   br label %while.end
68
69 while.end:                                        ; preds = %while.cond.while.end_crit_edge, %entry
70   ret i32 undef
71 }