Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/Transforms/InstCombine/minmax-fold.ll
Show First 20 Lines • Show All 920 Lines • ▼ Show 20 Lines | |||||
define float @not_min_of_min(i8 %i, float %x) { | define float @not_min_of_min(i8 %i, float %x) { | ||||
; CHECK-LABEL: @not_min_of_min( | ; CHECK-LABEL: @not_min_of_min( | ||||
; CHECK-NEXT: [[CMP1_INV:%.*]] = fcmp fast oge float [[X:%.*]], 1.000000e+00 | ; CHECK-NEXT: [[CMP1_INV:%.*]] = fcmp fast oge float [[X:%.*]], 1.000000e+00 | ||||
; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP1_INV]], float 1.000000e+00, float [[X]] | ; CHECK-NEXT: [[TMP1:%.*]] = select fast i1 [[CMP1_INV]], float 1.000000e+00, float [[X]] | ||||
; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X]], 2.000000e+00 | ; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X]], 2.000000e+00 | ||||
; CHECK-NEXT: [[TMP2:%.*]] = select fast i1 [[CMP2_INV]], float 2.000000e+00, float [[X]] | ; CHECK-NEXT: [[TMP2:%.*]] = select fast i1 [[CMP2_INV]], float 2.000000e+00, float [[X]] | ||||
; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i8 [[I:%.*]], 16 | ; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i8 [[I:%.*]], 16 | ||||
; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], float [[TMP1]], float [[TMP2]] | ; CHECK-NEXT: [[R:%.*]] = select fast i1 [[CMP3]], float [[TMP1]], float [[TMP2]] | ||||
; CHECK-NEXT: ret float [[R]] | ; CHECK-NEXT: ret float [[R]] | ||||
; | ; | ||||
%cmp1 = fcmp fast ult float %x, 1.0 | %cmp1 = fcmp fast ult float %x, 1.0 | ||||
%min1 = select i1 %cmp1, float %x, float 1.0 | %min1 = select i1 %cmp1, float %x, float 1.0 | ||||
%cmp2 = fcmp fast ult float %x, 2.0 | %cmp2 = fcmp fast ult float %x, 2.0 | ||||
%min2 = select i1 %cmp2, float %x, float 2.0 | %min2 = select i1 %cmp2, float %x, float 2.0 | ||||
%cmp3 = icmp ult i8 %i, 16 | %cmp3 = icmp ult i8 %i, 16 | ||||
%r = select i1 %cmp3, float %min1, float %min2 | %r = select i1 %cmp3, float %min1, float %min2 | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | ; | ||||
ret i37 %r | ret i37 %r | ||||
} | } | ||||
; Negative test | ; Negative test | ||||
; TODO: assert that instsimplify always gets this? | ; TODO: assert that instsimplify always gets this? | ||||
define i37 @add_umax_simplify(i37 %x) { | define i37 @add_umax_simplify(i37 %x) { | ||||
; CHECK-LABEL: @add_umax_simplify( | ; CHECK-LABEL: @add_umax_simplify( | ||||
; CHECK-NEXT: [[A:%.*]] = add nuw i37 [[X:%.*]], 42 | ; CHECK-NEXT: [[R:%.*]] = add nuw i37 [[X:%.*]], 42 | ||||
; CHECK-NEXT: ret i37 [[A]] | ; CHECK-NEXT: ret i37 [[R]] | ||||
; | ; | ||||
%a = add nuw i37 %x, 42 | %a = add nuw i37 %x, 42 | ||||
%c = icmp ugt i37 %a, 42 | %c = icmp ugt i37 %a, 42 | ||||
%r = select i1 %c, i37 %a, i37 42 | %r = select i1 %c, i37 %a, i37 42 | ||||
ret i37 %r | ret i37 %r | ||||
} | } | ||||
; Negative test | ; Negative test | ||||
▲ Show 20 Lines • Show All 426 Lines • Show Last 20 Lines |