1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
4 @G = extern_weak global i32
7 ; Do not merge bb1 into the entry block, it might trap.
9 define i32 @admiral(i32 %a, i32 %b) {
10 ; CHECK-LABEL: @admiral(
11 ; CHECK-NEXT: [[C:%.*]] = icmp sle i32 [[A:%.*]], [[B:%.*]]
12 ; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[BB1:%.*]]
14 ; CHECK-NEXT: [[D:%.*]] = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0
15 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[D]], i32 927, i32 42
16 ; CHECK-NEXT: br label [[COMMON_RET]]
18 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 42, [[TMP0:%.*]] ], [ [[SPEC_SELECT]], [[BB1]] ]
19 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
21 %c = icmp sle i32 %a, %b
22 br i1 %c, label %bb2, label %bb1
24 %d = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0
25 br i1 %d, label %bb6, label %bb2
32 define i32 @ackbar(i1 %c) {
33 ; CHECK-LABEL: @ackbar(
34 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB5:%.*]], label [[COMMON_RET:%.*]]
36 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 icmp sgt (i32 sdiv (i32 32767, i32 ptrtoint (i32* @G to i32)), i32 0), i32 42, i32 927
37 ; CHECK-NEXT: br label [[COMMON_RET]]
39 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 42, [[TMP0:%.*]] ], [ [[SPEC_SELECT]], [[BB5]] ]
40 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
42 br i1 %c, label %bb5, label %bb6
44 br i1 icmp sgt (i32 sdiv (i32 32767, i32 ptrtoint (i32* @G to i32)), i32 0), label %bb6, label %bb7
51 ; FP ops don't trap by default, so this is safe to hoist.
53 define i32 @tarp(i1 %c) {
55 ; CHECK-NEXT: common.ret:
56 ; CHECK-NEXT: [[C_NOT:%.*]] = xor i1 [[C:%.*]], true
57 ; CHECK-NEXT: [[BRMERGE:%.*]] = or i1 [[C_NOT]], fcmp oeq (float fdiv (float 3.000000e+00, float sitofp (i32 ptrtoint (i32* @G to i32) to float)), float 1.000000e+00)
58 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = select i1 [[BRMERGE]], i32 42, i32 927
59 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
61 br i1 %c, label %bb8, label %bb9
63 br i1 fcmp oeq (float fdiv (float 3.0, float sitofp (i32 ptrtoint (i32* @G to i32) to float)), float 1.0), label %bb9, label %bb10