brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · bc172f0 Raw
139 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=instcombine -S < %s | FileCheck %s3declare void @use_i8(i8)4define i8 @mul_selectp2_x(i8 %x, i1 %c) {5; CHECK-LABEL: @mul_selectp2_x(6; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], i8 1, i8 27; CHECK-NEXT:    [[R:%.*]] = shl i8 [[X:%.*]], [[TMP1]]8; CHECK-NEXT:    ret i8 [[R]]9;10  %s = select i1 %c, i8 2, i8 411  %r = mul i8 %s, %x12  ret i8 %r13}14 15 16define i8 @mul_selectp2_x_propegate_nuw(i8 %x, i1 %c) {17; CHECK-LABEL: @mul_selectp2_x_propegate_nuw(18; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], i8 1, i8 219; CHECK-NEXT:    [[R:%.*]] = shl nuw i8 [[X:%.*]], [[TMP1]]20; CHECK-NEXT:    ret i8 [[R]]21;22  %s = select i1 %c, i8 2, i8 423  %r = mul nuw nsw i8 %s, %x24  ret i8 %r25}26 27 28define i8 @mul_selectp2_x_multiuse_fixme(i8 %x, i1 %c) {29; CHECK-LABEL: @mul_selectp2_x_multiuse_fixme(30; CHECK-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], i8 2, i8 431; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C]], i8 1, i8 232; CHECK-NEXT:    [[R:%.*]] = shl i8 [[X:%.*]], [[TMP1]]33; CHECK-NEXT:    call void @use_i8(i8 [[S]])34; CHECK-NEXT:    ret i8 [[R]]35;36  %s = select i1 %c, i8 2, i8 437  %r = mul i8 %s, %x38  call void @use_i8(i8 %s)39  ret i8 %r40}41 42define i8 @mul_selectp2_x_non_const(i8 %x, i1 %c, i8 %yy) {43; CHECK-LABEL: @mul_selectp2_x_non_const(44; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], i8 1, i8 [[YY:%.*]]45; CHECK-NEXT:    [[R:%.*]] = shl i8 [[X:%.*]], [[TMP1]]46; CHECK-NEXT:    ret i8 [[R]]47;48  %y = shl i8 1, %yy49  %s = select i1 %c, i8 2, i8 %y50  %r = mul i8 %s, %x51  ret i8 %r52}53 54define i8 @mul_selectp2_x_non_const_multiuse(i8 %x, i1 %c, i8 %yy) {55; CHECK-LABEL: @mul_selectp2_x_non_const_multiuse(56; CHECK-NEXT:    [[Y:%.*]] = shl nuw i8 1, [[YY:%.*]]57; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], i8 1, i8 [[YY]]58; CHECK-NEXT:    [[R:%.*]] = shl i8 [[X:%.*]], [[TMP1]]59; CHECK-NEXT:    call void @use_i8(i8 [[Y]])60; CHECK-NEXT:    ret i8 [[R]]61;62  %y = shl i8 1, %yy63  %s = select i1 %c, i8 2, i8 %y64  %r = mul i8 %s, %x65  call void @use_i8(i8 %y)66  ret i8 %r67}68 69define i8 @mul_x_selectp2(i8 %xx, i1 %c) {70; CHECK-LABEL: @mul_x_selectp2(71; CHECK-NEXT:    [[X:%.*]] = mul i8 [[XX:%.*]], [[XX]]72; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], i8 3, i8 073; CHECK-NEXT:    [[R:%.*]] = shl i8 [[X]], [[TMP1]]74; CHECK-NEXT:    ret i8 [[R]]75;76  %x = mul i8 %xx, %xx77  %s = select i1 %c, i8 8, i8 178  %r = mul i8 %x, %s79  ret i8 %r80}81 82define i8 @mul_select_nonp2_x_fail(i8 %x, i1 %c) {83; CHECK-LABEL: @mul_select_nonp2_x_fail(84; CHECK-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], i8 2, i8 585; CHECK-NEXT:    [[R:%.*]] = mul i8 [[S]], [[X:%.*]]86; CHECK-NEXT:    ret i8 [[R]]87;88  %s = select i1 %c, i8 2, i8 589  %r = mul i8 %s, %x90  ret i8 %r91}92 93define <2 x i8> @mul_x_selectp2_vec(<2 x i8> %xx, i1 %c) {94; CHECK-LABEL: @mul_x_selectp2_vec(95; CHECK-NEXT:    [[X:%.*]] = mul <2 x i8> [[XX:%.*]], [[XX]]96; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[C:%.*]], <2 x i8> <i8 3, i8 4>, <2 x i8> <i8 2, i8 0>97; CHECK-NEXT:    [[R:%.*]] = shl <2 x i8> [[X]], [[TMP1]]98; CHECK-NEXT:    ret <2 x i8> [[R]]99;100  %x = mul <2 x i8> %xx, %xx101  %s = select i1 %c, <2 x i8> <i8 8, i8 16>, <2 x i8> <i8 4, i8 1>102  %r = mul <2 x i8> %x, %s103  ret <2 x i8> %r104}105 106 107define i8 @shl_add_log_may_cause_poison_pr62175_fail(i8 %x, i8 %y) {108; CHECK-LABEL: @shl_add_log_may_cause_poison_pr62175_fail(109; CHECK-NEXT:    [[SHL:%.*]] = shl i8 4, [[X:%.*]]110; CHECK-NEXT:    [[MUL:%.*]] = mul i8 [[Y:%.*]], [[SHL]]111; CHECK-NEXT:    ret i8 [[MUL]]112;113  %shl = shl i8 4, %x114  %mul = mul i8 %y, %shl115  ret i8 %mul116}117 118define i8 @shl_add_log_may_cause_poison_pr62175_with_nuw(i8 %x, i8 %y) {119; CHECK-LABEL: @shl_add_log_may_cause_poison_pr62175_with_nuw(120; CHECK-NEXT:    [[TMP1:%.*]] = add i8 [[X:%.*]], 2121; CHECK-NEXT:    [[MUL:%.*]] = shl i8 [[Y:%.*]], [[TMP1]]122; CHECK-NEXT:    ret i8 [[MUL]]123;124  %shl = shl nuw i8 4, %x125  %mul = mul i8 %y, %shl126  ret i8 %mul127}128 129define i8 @shl_add_log_may_cause_poison_pr62175_with_nsw(i8 %x, i8 %y) {130; CHECK-LABEL: @shl_add_log_may_cause_poison_pr62175_with_nsw(131; CHECK-NEXT:    [[TMP1:%.*]] = add i8 [[X:%.*]], 2132; CHECK-NEXT:    [[MUL:%.*]] = shl i8 [[Y:%.*]], [[TMP1]]133; CHECK-NEXT:    ret i8 [[MUL]]134;135  %shl = shl nsw i8 4, %x136  %mul = mul i8 %y, %shl137  ret i8 %mul138}139