]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/NewGVN/eliminate-ssacopy.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / NewGVN / eliminate-ssacopy.ll
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -newgvn -S < %s | FileCheck %s
3
4 ; Make sure the created ssa copies are cleaned up. See PR38804.
5
6 ; CHECK-NOT: ssa_copy
7
8 @b = external dso_local local_unnamed_addr global i32, align 4
9 @a = external dso_local local_unnamed_addr global i8, align 1
10 @f = external dso_local local_unnamed_addr global i16, align 2
11
12 define void @g() {
13 ; CHECK-LABEL: @g(
14 ; CHECK-NEXT:  entry:
15 ; CHECK-NEXT:    br i1 undef, label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
16 ; CHECK:       for.cond.preheader:
17 ; CHECK-NEXT:    unreachable
18 ; CHECK:       for.cond1thread-pre-split:
19 ; CHECK-NEXT:    br label [[FOR_END4_SPLIT:%.*]]
20 ; CHECK:       for.end4.split:
21 ; CHECK-NEXT:    br i1 true, label [[FOR_COND6_PREHEADER:%.*]], label [[IF_END11:%.*]]
22 ; CHECK:       for.cond6.preheader:
23 ; CHECK-NEXT:    br i1 undef, label [[FOR_COND6_PREHEADER3:%.*]], label [[IF_END11_LOOPEXIT:%.*]]
24 ; CHECK:       for.cond6.preheader3:
25 ; CHECK-NEXT:    br label [[IF_END11_LOOPEXIT]]
26 ; CHECK:       if.end11.loopexit:
27 ; CHECK-NEXT:    [[STOREMERGE_LCSSA:%.*]] = phi i32 [ 0, [[FOR_COND6_PREHEADER]] ], [ 1, [[FOR_COND6_PREHEADER3]] ]
28 ; CHECK-NEXT:    store i32 [[STOREMERGE_LCSSA]], i32* @b, align 4
29 ; CHECK-NEXT:    br label [[IF_END11]]
30 ; CHECK:       if.end11:
31 ; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @b, align 4
32 ; CHECK-NEXT:    [[TMP1:%.*]] = load i8, i8* @a, align 1
33 ; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[TMP1]] to i32
34 ; CHECK-NEXT:    [[CMP12:%.*]] = icmp eq i32 [[TMP0]], [[CONV]]
35 ; CHECK-NEXT:    br i1 [[CMP12]], label [[IF_THEN14:%.*]], label [[IF_END16:%.*]]
36 ; CHECK:       if.then14:
37 ; CHECK-NEXT:    [[CONV15:%.*]] = trunc i32 [[TMP0]] to i16
38 ; CHECK-NEXT:    store i16 [[CONV15]], i16* @f, align 2
39 ; CHECK-NEXT:    unreachable
40 ; CHECK:       if.end16:
41 ; CHECK-NEXT:    ret void
42 ;
43 entry:
44   %tobool = icmp eq i32 undef, 0
45   br i1 %tobool, label %for.cond1thread-pre-split, label %for.cond.preheader
46
47 for.cond.preheader:                               ; preds = %entry
48   unreachable
49
50 for.cond1thread-pre-split:                        ; preds = %entry
51   br label %for.end4.split
52
53 for.end4.split:                                   ; preds = %for.cond1thread-pre-split
54   br i1 %tobool, label %for.cond6.preheader, label %if.end11
55
56 for.cond6.preheader:                              ; preds = %for.end4.split
57   br i1 undef, label %for.cond6.preheader3, label %if.end11.loopexit
58
59 for.cond6.preheader3:                             ; preds = %for.cond6.preheader
60   br label %if.end11.loopexit
61
62 if.end11.loopexit:                                ; preds = %for.cond6.preheader3, %for.cond6.preheader
63   %storemerge.lcssa = phi i32 [ 0, %for.cond6.preheader ], [ 1, %for.cond6.preheader3 ]
64   store i32 %storemerge.lcssa, i32* @b, align 4
65   br label %if.end11
66
67 if.end11:                                         ; preds = %if.end11.loopexit, %for.end4.split
68   %0 = load i32, i32* @b, align 4
69   %1 = load i8, i8* @a, align 1
70   %conv = sext i8 %1 to i32
71   %cmp12 = icmp eq i32 %0, %conv
72   br i1 %cmp12, label %if.then14, label %if.end16
73
74 if.then14:                                        ; preds = %if.end11
75   %conv15 = trunc i32 %0 to i16
76   store i16 %conv15, i16* @f, align 2
77   unreachable
78
79 if.end16:                                         ; preds = %if.end11
80   ret void
81 }