1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -passes=newgvn -S < %s | FileCheck %s
4 @c = global i32 0, align 4
6 ; Function Attrs: nounwind optsize uwtable
7 define i32 @main(i1 %cond1, i32 %arg0, i32 %arg1) {
8 ; CHECK-LABEL: define i32 @main(
9 ; CHECK-SAME: i1 [[COND1:%.*]], i32 [[ARG0:%.*]], i32 [[ARG1:%.*]]) {
11 ; CHECK-NEXT: br i1 [[COND1]], label [[BB1:%.*]], label [[BB3:%.*]]
13 ; CHECK-NEXT: [[XOR1:%.*]] = xor i32 [[ARG0]], 1
14 ; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[ARG1]], 0
15 ; CHECK-NEXT: br i1 [[COND2]], label [[BB3]], label [[BB2:%.*]]
17 ; CHECK-NEXT: [[COND3:%.*]] = icmp ne i32 [[XOR1]], 0
18 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[COND3]])
19 ; CHECK-NEXT: br label [[BB3]]
21 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ [[XOR1]], [[BB1]] ], [ [[XOR1]], [[BB2]] ]
22 ; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[PHI]], -1
23 ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr @c, align 4
24 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[LD]], [[XOR2]]
25 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[OR]], 0
26 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[PHI]], 0
27 ; CHECK-NEXT: [[COND4:%.*]] = or i1 [[CMP1]], [[CMP2]]
28 ; CHECK-NEXT: br i1 [[COND4]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
30 ; CHECK-NEXT: ret i32 0
32 ; CHECK-NEXT: ret i32 1
44 br i1 %cond1, label %bb1, label %bb3
47 %xor1 = xor i32 %arg0, 1
48 %cond2 = icmp eq i32 %arg1, 0
49 br i1 %cond2, label %bb3, label %bb2
52 %cond3 = icmp ne i32 %xor1, 0
53 tail call void @llvm.assume(i1 %cond3)
56 bb3: ; preds = %bb2, %bb1, %entry
57 %phi = phi i32 [ undef, %entry ], [ %xor1, %bb1 ], [ %xor1, %bb2 ]
58 %xor2 = xor i32 %phi, -1
59 %ld = load i32, ptr @c, align 4
60 %or = or i32 %ld, %xor2
61 %cmp1 = icmp eq i32 %or, 0
62 %cmp2 = icmp eq i32 %phi, 0
63 %cond4 = or i1 %cmp1, %cmp2
64 br i1 %cond4, label %exit1, label %exit2
73 declare void @llvm.assume(i1 noundef)