1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -simplifycfg -S | FileCheck %s 3 4; Reduced from arm_abs_q31() from CMSIS DSP suite. 5; https://reviews.llvm.org/D65148#1629010 6 7define i32 @abs_with_clamp(i32 %arg) { 8; CHECK-LABEL: @abs_with_clamp( 9; CHECK-NEXT: begin: 10; CHECK-NEXT: [[IS_POSITIVE:%.*]] = icmp sgt i32 [[ARG:%.*]], 0 11; CHECK-NEXT: [[IS_INT_MIN:%.*]] = icmp eq i32 [[ARG]], -2147483648 12; CHECK-NEXT: [[NEGATED:%.*]] = sub nsw i32 0, [[ARG]] 13; CHECK-NEXT: [[ABS:%.*]] = select i1 [[IS_INT_MIN]], i32 2147483647, i32 [[NEGATED]] 14; CHECK-NEXT: [[TMP6:%.*]] = select i1 [[IS_POSITIVE]], i32 [[ARG]], i32 [[ABS]] 15; CHECK-NEXT: ret i32 [[TMP6]] 16; 17begin: 18 %is_positive = icmp sgt i32 %arg, 0 19 br i1 %is_positive, label %end, label %negative 20 21negative: ; preds = %begin 22 %is_int_min = icmp eq i32 %arg, -2147483648 23 %negated = sub nsw i32 0, %arg 24 %abs = select i1 %is_int_min, i32 2147483647, i32 %negated 25 br label %end 26 27end: ; preds = %negative, %begin 28 %tmp6 = phi i32 [ %arg, %begin ], [ %abs, %negative ] 29 ret i32 %tmp6 30} 31