1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -newgvn %s -S | FileCheck %s
6 ; Make sure !tbaa metadata is preserved when only ssa_copy calls introduced by
7 ; PredicateInfo are replaced.
9 define i32 @test(i32* %p1, i32* %p2, i1 %c) {
12 ; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[P1:%.*]], align 8, !tbaa !0
13 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp slt i32 [[LV]], 1
14 ; CHECK-NEXT: br i1 [[CMP_1]], label [[EXIT:%.*]], label [[IF_FALSE:%.*]]
16 ; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT]], label [[FOR_CHECK:%.*]]
18 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp sgt i32 [[LV]], 0
19 ; CHECK-NEXT: br i1 [[CMP_2]], label [[FOR_PH:%.*]], label [[EXIT]]
21 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
23 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[FOR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
24 ; CHECK-NEXT: call void @use(i32 [[IV]])
25 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
26 ; CHECK-NEXT: [[CMP_3:%.*]] = icmp ne i32 [[IV_NEXT]], [[LV]]
27 ; CHECK-NEXT: br i1 [[CMP_3]], label [[FOR_BODY]], label [[EXIT]]
29 ; CHECK-NEXT: ret i32 [[LV]]
32 %lv = load i32, i32* %p1, align 8, !tbaa !0
33 %cmp.1 = icmp slt i32 %lv, 1
34 br i1 %cmp.1, label %exit, label %if.false
36 if.false: ; preds = %entry
37 br i1 %c, label %exit, label %for.check
39 for.check: ; preds = %if.false
40 %cmp.2 = icmp sgt i32 %lv, 0
41 br i1 %cmp.2, label %for.ph, label %exit
43 for.ph: ; preds = %for.check
46 for.body: ; preds = %for.body, %for.ph
47 %iv = phi i32 [ 0, %for.ph ], [ %iv.next, %for.body ]
48 call void @use(i32 %iv)
49 %iv.next = add nuw nsw i32 %iv, 1
50 %cmp.3 = icmp ne i32 %iv.next, %lv
51 br i1 %cmp.3, label %for.body, label %exit
53 exit: ; preds = %for.body, %for.check, %if.false, %entry
58 !1 = !{!"FULL", !2, i64 0, !2, i64 4, !3, i64 8}
59 !2 = !{!"int", !3, i64 0}
60 !3 = !{!"omnipotent char", !4, i64 0}
61 !4 = !{!"Simple C/C++ TBAA"}