1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=newgvn < %s | FileCheck %s
4 define i32 @unsafe(i1 %arg, i32 %arg1) {
5 ; CHECK-LABEL: define i32 @unsafe(
6 ; CHECK-SAME: i1 [[ARG:%.*]], i32 [[ARG1:%.*]]) {
7 ; CHECK-NEXT: [[BB:.*:]]
8 ; CHECK-NEXT: br label %[[BB4:.*]]
10 ; CHECK-NEXT: br i1 [[ARG]], label %[[BB6:.*]], label %[[BB5:.*]]
12 ; CHECK-NEXT: br label %[[BB6]]
14 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[ARG1]], %[[BB5]] ], [ 0, %[[BB4]] ]
15 ; CHECK-NEXT: [[SREM:%.*]] = srem i32 [[ARG1]], [[PHI]]
16 ; CHECK-NEXT: store i32 [[SREM]], ptr null, align 4
17 ; CHECK-NEXT: br i1 [[ARG]], label %[[BB8:.*]], label %[[BB7:.*]]
19 ; CHECK-NEXT: br i1 true, label %[[BB8]], label %[[BB5]]
21 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i32 [ [[ARG1]], %[[BB6]] ], [ 0, %[[BB7]] ]
22 ; CHECK-NEXT: [[PHI9:%.*]] = phi i32 [ 0, %[[BB7]] ], [ 1, %[[BB6]] ]
23 ; CHECK-NEXT: store i32 [[PHIOFOPS]], ptr null, align 4
24 ; CHECK-NEXT: br label %[[BB4]]
29 bb4: ; preds = %bb8, %bb
30 br i1 %arg, label %bb6, label %bb5
32 bb5: ; preds = %bb7, %bb4
35 bb6: ; preds = %bb5, %bb4
36 %phi = phi i32 [ %arg1, %bb5 ], [ 0, %bb4 ]
37 %or = or i32 %phi, %arg1
38 %srem = srem i32 %or, %phi
39 store i32 %srem, ptr null, align 4
40 br i1 %arg, label %bb8, label %bb7
43 br i1 true, label %bb8, label %bb5
45 bb8: ; preds = %bb7, %bb6
46 %phi9 = phi i32 [ 0, %bb7 ], [ 1, %bb6 ]
47 %mul = mul i32 %phi9, %or
48 store i32 %mul, ptr null, align 4
52 define i32 @unsafe_load(i1 %arg) {
53 ; CHECK-LABEL: define i32 @unsafe_load(
54 ; CHECK-SAME: i1 [[ARG:%.*]]) {
55 ; CHECK-NEXT: [[BB:.*:]]
56 ; CHECK-NEXT: br label %[[BB1:.*]]
58 ; CHECK-NEXT: br i1 [[ARG]], label %[[BB3:.*]], label %[[BB2:.*]]
60 ; CHECK-NEXT: br label %[[BB3]]
62 ; CHECK-NEXT: [[PHI4:%.*]] = phi i32 [ 1, %[[BB2]] ], [ 0, %[[BB1]] ]
63 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr null, align 4
64 ; CHECK-NEXT: [[SREM:%.*]] = srem i32 [[LOAD]], [[PHI4]]
65 ; CHECK-NEXT: store i32 [[SREM]], ptr null, align 4
66 ; CHECK-NEXT: br i1 [[ARG]], label %[[BB6:.*]], label %[[BB5:.*]]
68 ; CHECK-NEXT: br i1 true, label %[[BB6]], label %[[BB2]]
70 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i32 [ [[LOAD]], %[[BB3]] ], [ 0, %[[BB5]] ]
71 ; CHECK-NEXT: [[PHI7:%.*]] = phi i32 [ 0, %[[BB5]] ], [ 1, %[[BB3]] ]
72 ; CHECK-NEXT: store i32 [[PHIOFOPS]], ptr null, align 4
73 ; CHECK-NEXT: br label %[[BB1]]
78 bb1: ; preds = %bb6, %bb
79 br i1 %arg, label %bb3, label %bb2
81 bb2: ; preds = %bb5, %bb1
82 %phi = phi i32 [ 1, %bb1 ], [ 0, %bb5 ]
85 bb3: ; preds = %bb2, %bb1
86 %phi4 = phi i32 [ %phi, %bb2 ], [ 0, %bb1 ]
87 %load = load i32, ptr null, align 4
88 %srem = srem i32 %load, %phi4
89 store i32 %srem, ptr null, align 4
90 br i1 %arg, label %bb6, label %bb5
93 br i1 true, label %bb6, label %bb2
95 bb6: ; preds = %bb5, %bb3
96 %phi7 = phi i32 [ 0, %bb5 ], [ 1, %bb3 ]
97 %mul = mul i32 %phi7, %load
98 store i32 %mul, ptr null, align 4