1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -simplifycfg -S | FileCheck %s 3 4@G = extern_weak global i32 5 6; PR3354 7; Do not merge bb1 into the entry block, it might trap. 8 9define 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 %bb2, label %bb1 13; CHECK: bb1: 14; CHECK-NEXT: [[D:%.*]] = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0 15; CHECK-NEXT: [[DOT:%.*]] = select i1 [[D]], i32 927, i32 42 16; CHECK-NEXT: br label %bb2 17; CHECK: bb2: 18; CHECK-NEXT: [[MERGE:%.*]] = phi i32 [ 42, %0 ], [ [[DOT]], %bb1 ] 19; CHECK-NEXT: ret i32 [[MERGE]] 20; 21 %c = icmp sle i32 %a, %b 22 br i1 %c, label %bb2, label %bb1 23bb1: 24 %d = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0 25 br i1 %d, label %bb6, label %bb2 26bb2: 27 ret i32 42 28bb6: 29 ret i32 927 30} 31 32define i32 @ackbar(i1 %c) { 33; CHECK-LABEL: @ackbar( 34; CHECK-NEXT: br i1 %c, label %bb5, label %bb6 35; CHECK: bb5: 36; CHECK-NEXT: [[DOT:%.*]] = 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 %bb6 38; CHECK: bb6: 39; CHECK-NEXT: [[MERGE:%.*]] = phi i32 [ 42, %0 ], [ [[DOT]], %bb5 ] 40; CHECK-NEXT: ret i32 [[MERGE]] 41; 42 br i1 %c, label %bb5, label %bb6 43bb5: 44 br i1 icmp sgt (i32 sdiv (i32 32767, i32 ptrtoint (i32* @G to i32)), i32 0), label %bb6, label %bb7 45bb6: 46 ret i32 42 47bb7: 48 ret i32 927 49} 50 51; FP ops don't trap by default, so this is safe to hoist. 52 53define i32 @tarp(i1 %c) { 54; CHECK-LABEL: @tarp( 55; CHECK-NEXT: bb9: 56; CHECK-NEXT: [[DOT:%.*]] = select i1 fcmp oeq (float fdiv (float 3.000000e+00, float sitofp (i32 ptrtoint (i32* @G to i32) to float)), float 1.000000e+00), i32 42, i32 927 57; CHECK-NEXT: [[MERGE:%.*]] = select i1 %c, i32 [[DOT]], i32 42 58; CHECK-NEXT: ret i32 [[MERGE]] 59; 60 br i1 %c, label %bb8, label %bb9 61bb8: 62 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 63bb9: 64 ret i32 42 65bb10: 66 ret i32 927 67} 68