brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · 916c41f Raw
173 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s3 4define i16 @udiv_one_arg(i8 %x) {5; CHECK-LABEL: @udiv_one_arg(6; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X:%.*]] to i167; CHECK-NEXT:    [[DIV:%.*]] = udiv i16 [[ZEXT]], 428; CHECK-NEXT:    ret i16 [[DIV]]9;10  %zext = zext i8 %x to i3211  %div = udiv i32 %zext, 4212  %trunc = trunc i32 %div to i1613  ret i16 %trunc14}15 16define i16 @udiv_two_args(i16 %x, i16 %y) {17; CHECK-LABEL: @udiv_two_args(18; CHECK-NEXT:    [[I0:%.*]] = udiv i16 [[X:%.*]], [[Y:%.*]]19; CHECK-NEXT:    ret i16 [[I0]]20;21  %zextx = zext i16 %x to i3222  %zexty = zext i16 %y to i3223  %i0 = udiv i32 %zextx, %zexty24  %r = trunc i32 %i0 to i1625  ret i16 %r26}27 28; Negative test29define i16 @udiv_big_const(i8 %x) {30; CHECK-LABEL: @udiv_big_const(31; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X:%.*]] to i3232; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[ZEXT]], 7000033; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i32 [[DIV]] to i1634; CHECK-NEXT:    ret i16 [[TRUNC]]35;36  %zext = zext i8 %x to i3237  %div = udiv i32 %zext, 7000038  %trunc = trunc i32 %div to i1639  ret i16 %trunc40}41 42define <2 x i16> @udiv_vector(<2 x i8> %x) {43; CHECK-LABEL: @udiv_vector(44; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i16>45; CHECK-NEXT:    [[S:%.*]] = udiv <2 x i16> [[Z]], <i16 4, i16 10>46; CHECK-NEXT:    ret <2 x i16> [[S]]47;48  %z = zext <2 x i8> %x to <2 x i32>49  %s = udiv <2 x i32> %z, <i32 4, i32 10>50  %t = trunc <2 x i32> %s to <2 x i16>51  ret <2 x i16> %t52}53 54; Negative test: can only fold to <2 x i16>, requiring new vector type55define <2 x i8> @udiv_vector_need_new_vector_type(<2 x i8> %x) {56; CHECK-LABEL: @udiv_vector_need_new_vector_type(57; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>58; CHECK-NEXT:    [[S:%.*]] = udiv <2 x i32> [[Z]], <i32 4, i32 500>59; CHECK-NEXT:    [[T:%.*]] = trunc <2 x i32> [[S]] to <2 x i8>60; CHECK-NEXT:    ret <2 x i8> [[T]]61;62  %z = zext <2 x i8> %x to <2 x i32>63  %s = udiv <2 x i32> %z, <i32 4, i32 500>64  %t = trunc <2 x i32> %s to <2 x i8>65  ret <2 x i8> %t66}67 68; Negative test69define <2 x i16> @udiv_vector_big_const(<2 x i8> %x) {70; CHECK-LABEL: @udiv_vector_big_const(71; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>72; CHECK-NEXT:    [[S:%.*]] = udiv <2 x i32> [[Z]], <i32 16, i32 70000>73; CHECK-NEXT:    [[T:%.*]] = trunc <2 x i32> [[S]] to <2 x i16>74; CHECK-NEXT:    ret <2 x i16> [[T]]75;76  %z = zext <2 x i8> %x to <2 x i32>77  %s = udiv <2 x i32> %z, <i32 16, i32 70000>78  %t = trunc <2 x i32> %s to <2 x i16>79  ret <2 x i16> %t80}81 82define i16 @udiv_exact(i16 %x, i16 %y) {83; CHECK-LABEL: @udiv_exact(84; CHECK-NEXT:    [[I0:%.*]] = udiv exact i16 [[X:%.*]], [[Y:%.*]]85; CHECK-NEXT:    ret i16 [[I0]]86;87  %zextx = zext i16 %x to i3288  %zexty = zext i16 %y to i3289  %i0 = udiv exact i32 %zextx, %zexty90  %r = trunc i32 %i0 to i1691  ret i16 %r92}93 94 95define i16 @urem_one_arg(i8 %x) {96; CHECK-LABEL: @urem_one_arg(97; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X:%.*]] to i1698; CHECK-NEXT:    [[DIV:%.*]] = urem i16 [[ZEXT]], 4299; CHECK-NEXT:    ret i16 [[DIV]]100;101  %zext = zext i8 %x to i32102  %div = urem i32 %zext, 42103  %trunc = trunc i32 %div to i16104  ret i16 %trunc105}106 107define i16 @urem_two_args(i16 %x, i16 %y) {108; CHECK-LABEL: @urem_two_args(109; CHECK-NEXT:    [[I0:%.*]] = urem i16 [[X:%.*]], [[Y:%.*]]110; CHECK-NEXT:    ret i16 [[I0]]111;112  %zextx = zext i16 %x to i32113  %zexty = zext i16 %y to i32114  %i0 = urem i32 %zextx, %zexty115  %r = trunc i32 %i0 to i16116  ret i16 %r117}118 119; Negative test120define i16 @urem_big_const(i8 %x) {121; CHECK-LABEL: @urem_big_const(122; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X:%.*]] to i32123; CHECK-NEXT:    [[DIV:%.*]] = urem i32 [[ZEXT]], 70000124; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i32 [[DIV]] to i16125; CHECK-NEXT:    ret i16 [[TRUNC]]126;127  %zext = zext i8 %x to i32128  %div = urem i32 %zext, 70000129  %trunc = trunc i32 %div to i16130  ret i16 %trunc131}132 133define <2 x i16> @urem_vector(<2 x i8> %x) {134; CHECK-LABEL: @urem_vector(135; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i16>136; CHECK-NEXT:    [[S:%.*]] = urem <2 x i16> [[Z]], <i16 4, i16 10>137; CHECK-NEXT:    ret <2 x i16> [[S]]138;139  %z = zext <2 x i8> %x to <2 x i32>140  %s = urem <2 x i32> %z, <i32 4, i32 10>141  %t = trunc <2 x i32> %s to <2 x i16>142  ret <2 x i16> %t143}144 145; Negative test: can only fold to <2 x i16>, requiring new vector type146define <2 x i8> @urem_vector_need_new_vector_type(<2 x i8> %x) {147; CHECK-LABEL: @urem_vector_need_new_vector_type(148; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>149; CHECK-NEXT:    [[S:%.*]] = urem <2 x i32> [[Z]], <i32 500, i32 10>150; CHECK-NEXT:    [[T:%.*]] = trunc <2 x i32> [[S]] to <2 x i8>151; CHECK-NEXT:    ret <2 x i8> [[T]]152;153  %z = zext <2 x i8> %x to <2 x i32>154  %s = urem <2 x i32> %z, <i32 500, i32 10>155  %t = trunc <2 x i32> %s to <2 x i8>156  ret <2 x i8> %t157}158 159; Negative test160define <2 x i16> @urem_vector_big_const(<2 x i8> %x) {161; CHECK-LABEL: @urem_vector_big_const(162; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>163; CHECK-NEXT:    [[S:%.*]] = urem <2 x i32> [[Z]], <i32 16, i32 70000>164; CHECK-NEXT:    [[T:%.*]] = trunc <2 x i32> [[S]] to <2 x i16>165; CHECK-NEXT:    ret <2 x i16> [[T]]166;167  %z = zext <2 x i8> %x to <2 x i32>168  %s = urem <2 x i32> %z, <i32 16, i32 70000>169  %t = trunc <2 x i32> %s to <2 x i16>170  ret <2 x i16> %t171}172 173