brintos

brintos / llvm-project-archived public Read only

0
0
Text · 15.2 KiB · 812b4d8 Raw
336 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt -passes=instcombine -S %s | FileCheck %s3 4define <2 x i8> @select_icmp_insertelement_eq(<2 x i8> %x, <2 x i8> %y, i8 %i) {5; CHECK-LABEL: define <2 x i8> @select_icmp_insertelement_eq(6; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]], i8 [[I:%.*]]) {7; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[Y]], splat (i8 2)8; CHECK-NEXT:    [[INSERT:%.*]] = insertelement <2 x i8> splat (i8 2), i8 0, i8 [[I]]9; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[INSERT]], <2 x i8> [[X]]10; CHECK-NEXT:    ret <2 x i8> [[RETVAL]]11;12  %cmp = icmp eq <2 x i8> %y, <i8 2, i8 2>13  %insert = insertelement <2 x i8> %y, i8 0, i8 %i14  %retval = select <2 x i1> %cmp, <2 x i8> %insert, <2 x i8> %x15  ret <2 x i8> %retval16}17 18define <2 x i8> @select_icmp_insertelement_ne(<2 x i8> %x, <2 x i8> %y, i8 %i) {19; CHECK-LABEL: define <2 x i8> @select_icmp_insertelement_ne(20; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]], i8 [[I:%.*]]) {21; CHECK-NEXT:    [[CMP_NOT:%.*]] = icmp eq <2 x i8> [[Y]], splat (i8 2)22; CHECK-NEXT:    [[INSERT:%.*]] = insertelement <2 x i8> splat (i8 2), i8 0, i8 [[I]]23; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[CMP_NOT]], <2 x i8> [[INSERT]], <2 x i8> [[X]]24; CHECK-NEXT:    ret <2 x i8> [[RETVAL]]25;26  %cmp = icmp ne <2 x i8> %y, <i8 2, i8 2>27  %insert = insertelement <2 x i8> %y, i8 0, i8 %i28  %retval = select <2 x i1> %cmp, <2 x i8> %x, <2 x i8> %insert29  ret <2 x i8> %retval30}31 32define <2 x i8> @select_icmp_shufflevector_identity(<2 x i8> %x, <2 x i8> %y) {33; CHECK-LABEL: define <2 x i8> @select_icmp_shufflevector_identity(34; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {35; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[Y]], splat (i8 2)36; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> splat (i8 2), <2 x i8> [[X]]37; CHECK-NEXT:    ret <2 x i8> [[RETVAL]]38;39  %cmp = icmp eq <2 x i8> %y, <i8 2, i8 2>40  %shuffle = shufflevector <2 x i8> %y, <2 x i8> poison, <2 x i32> <i32 0, i32 1>41  %retval = select <2 x i1> %cmp, <2 x i8> %shuffle, <2 x i8> %x42  ret <2 x i8> %retval43}44 45define <4 x i8> @select_icmp_shufflevector_select(<4 x i8> %x, <4 x i8> %y, <4 x i8> %z) {46; CHECK-LABEL: define <4 x i8> @select_icmp_shufflevector_select(47; CHECK-SAME: <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i8> [[Z:%.*]]) {48; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <4 x i8> [[Y]], splat (i8 2)49; CHECK-NEXT:    [[SHUFFLE:%.*]] = shufflevector <4 x i8> [[Z]], <4 x i8> <i8 poison, i8 2, i8 poison, i8 2>, <4 x i32> <i32 0, i32 5, i32 2, i32 7>50; CHECK-NEXT:    [[RETVAL:%.*]] = select <4 x i1> [[CMP]], <4 x i8> [[SHUFFLE]], <4 x i8> [[X]]51; CHECK-NEXT:    ret <4 x i8> [[RETVAL]]52;53  %cmp = icmp eq <4 x i8> %y, <i8 2, i8 2, i8 2, i8 2>54  %shuffle = shufflevector <4 x i8> %y, <4 x i8> %z, <4 x i32> <i32 4, i32 1, i32 6, i32 3>55  %retval = select <4 x i1> %cmp, <4 x i8> %shuffle, <4 x i8> %x56  ret <4 x i8> %retval57}58 59define <2 x i8> @select_icmp_shufflevector_lanecrossing(<2 x i8> %x, <2 x i8> %y) {60; CHECK-LABEL: define <2 x i8> @select_icmp_shufflevector_lanecrossing(61; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {62; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[Y]], splat (i8 2)63; CHECK-NEXT:    [[SHUFFLE:%.*]] = shufflevector <2 x i8> [[Y]], <2 x i8> poison, <2 x i32> <i32 1, i32 0>64; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[SHUFFLE]], <2 x i8> [[X]]65; CHECK-NEXT:    ret <2 x i8> [[RETVAL]]66;67  %cmp = icmp eq <2 x i8> %y, <i8 2, i8 2>68  %shuffle = shufflevector <2 x i8> %y, <2 x i8> poison, <2 x i32> <i32 1, i32 0>69  %retval = select <2 x i1> %cmp, <2 x i8> %shuffle, <2 x i8> %x70  ret <2 x i8> %retval71}72 73declare <2 x i8> @fn(<2 x i8>) speculatable74 75define <2 x i8> @select_icmp_call_possibly_lanecrossing(<2 x i8> %x, <2 x i8> %y) {76; CHECK-LABEL: define <2 x i8> @select_icmp_call_possibly_lanecrossing(77; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {78; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[Y]], splat (i8 2)79; CHECK-NEXT:    [[CALL:%.*]] = call <2 x i8> @fn(<2 x i8> [[Y]])80; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[CALL]], <2 x i8> [[X]]81; CHECK-NEXT:    ret <2 x i8> [[RETVAL]]82;83  %cmp = icmp eq <2 x i8> %y, <i8 2, i8 2>84  %call = call <2 x i8> @fn(<2 x i8> %y)85  %retval = select <2 x i1> %cmp, <2 x i8> %call, <2 x i8> %x86  ret <2 x i8> %retval87}88 89define float @select_fcmp_fadd_oeq_not_zero(float %x, float %y) {90; CHECK-LABEL: define float @select_fcmp_fadd_oeq_not_zero(91; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {92; CHECK-NEXT:    [[FCMP:%.*]] = fcmp oeq float [[Y]], 2.000000e+0093; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], 2.000000e+0094; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[FADD]], float [[X]]95; CHECK-NEXT:    ret float [[RETVAL]]96;97  %fcmp = fcmp oeq float %y, 2.098  %fadd = fadd float %x, %y99  %retval = select i1 %fcmp, float %fadd, float %x100  ret float %retval101}102 103define float @select_fcmp_fadd_une_not_zero(float %x, float %y) {104; CHECK-LABEL: define float @select_fcmp_fadd_une_not_zero(105; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {106; CHECK-NEXT:    [[FCMP:%.*]] = fcmp une float [[Y]], 2.000000e+00107; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], 2.000000e+00108; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[X]], float [[FADD]]109; CHECK-NEXT:    ret float [[RETVAL]]110;111  %fcmp = fcmp une float %y, 2.0112  %fadd = fadd float %x, %y113  %retval = select i1 %fcmp, float %x, float %fadd114  ret float %retval115}116 117define float @select_fcmp_fadd_ueq_nnan_not_zero(float %x, float %y) {118; CHECK-LABEL: define float @select_fcmp_fadd_ueq_nnan_not_zero(119; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {120; CHECK-NEXT:    [[FCMP:%.*]] = fcmp nnan ueq float [[Y]], 2.000000e+00121; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], 2.000000e+00122; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[FADD]], float [[X]]123; CHECK-NEXT:    ret float [[RETVAL]]124;125  %fcmp = fcmp nnan ueq float %y, 2.0126  %fadd = fadd float %x, %y127  %retval = select i1 %fcmp, float %fadd, float %x128  ret float %retval129}130 131define float @select_fcmp_fadd_one_nnan_not_zero(float %x, float %y) {132; CHECK-LABEL: define float @select_fcmp_fadd_one_nnan_not_zero(133; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {134; CHECK-NEXT:    [[FCMP:%.*]] = fcmp nnan one float [[Y]], 2.000000e+00135; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], 2.000000e+00136; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[X]], float [[FADD]]137; CHECK-NEXT:    ret float [[RETVAL]]138;139  %fcmp = fcmp nnan one float %y, 2.0140  %fadd = fadd float %x, %y141  %retval = select i1 %fcmp, float %x, float %fadd142  ret float %retval143}144 145define float @select_fcmp_fadd_ueq(float %x, float %y) {146; CHECK-LABEL: define float @select_fcmp_fadd_ueq(147; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {148; CHECK-NEXT:    [[FCMP:%.*]] = fcmp ueq float [[Y]], 2.000000e+00149; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], [[Y]]150; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[FADD]], float [[X]]151; CHECK-NEXT:    ret float [[RETVAL]]152;153  %fcmp = fcmp ueq float %y, 2.0154  %fadd = fadd float %x, %y155  %retval = select i1 %fcmp, float %fadd, float %x156  ret float %retval157}158 159define float @select_fcmp_fadd_one(float %x, float %y) {160; CHECK-LABEL: define float @select_fcmp_fadd_one(161; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {162; CHECK-NEXT:    [[FCMP:%.*]] = fcmp one float [[Y]], 2.000000e+00163; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], [[Y]]164; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[X]], float [[FADD]]165; CHECK-NEXT:    ret float [[RETVAL]]166;167  %fcmp = fcmp one float %y, 2.0168  %fadd = fadd float %x, %y169  %retval = select i1 %fcmp, float %x, float %fadd170  ret float %retval171}172 173define float @select_fcmp_fadd_oeq_zero(float %x, float %y) {174; CHECK-LABEL: define float @select_fcmp_fadd_oeq_zero(175; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {176; CHECK-NEXT:    [[FCMP:%.*]] = fcmp oeq float [[Y]], 0.000000e+00177; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], [[Y]]178; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[FADD]], float [[X]]179; CHECK-NEXT:    ret float [[RETVAL]]180;181  %fcmp = fcmp oeq float %y, 0.0182  %fadd = fadd float %x, %y183  %retval = select i1 %fcmp, float %fadd, float %x184  ret float %retval185}186 187define float @select_fcmp_fadd_une_zero(float %x, float %y) {188; CHECK-LABEL: define float @select_fcmp_fadd_une_zero(189; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {190; CHECK-NEXT:    [[FCMP:%.*]] = fcmp une float [[Y]], 0.000000e+00191; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[X]], [[Y]]192; CHECK-NEXT:    [[RETVAL:%.*]] = select i1 [[FCMP]], float [[X]], float [[FADD]]193; CHECK-NEXT:    ret float [[RETVAL]]194;195  %fcmp = fcmp une float %y, 0.0196  %fadd = fadd float %x, %y197  %retval = select i1 %fcmp, float %x, float %fadd198  ret float %retval199}200 201define <2 x float> @select_fcmp_fadd_oeq_not_zero_vec(<2 x float> %x, <2 x float> %y) {202; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_oeq_not_zero_vec(203; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {204; CHECK-NEXT:    [[FCMP:%.*]] = fcmp oeq <2 x float> [[Y]], splat (float 2.000000e+00)205; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], splat (float 2.000000e+00)206; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[FADD]], <2 x float> [[X]]207; CHECK-NEXT:    ret <2 x float> [[RETVAL]]208;209  %fcmp = fcmp oeq <2 x float> %y, <float 2.0, float 2.0>210  %fadd = fadd <2 x float> %x, %y211  %retval = select <2 x i1> %fcmp, <2 x float> %fadd, <2 x float> %x212  ret <2 x float> %retval213}214 215define <2 x float> @select_fcmp_fadd_une_not_zero_vec(<2 x float> %x, <2 x float> %y) {216; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_une_not_zero_vec(217; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {218; CHECK-NEXT:    [[FCMP:%.*]] = fcmp une <2 x float> [[Y]], splat (float 2.000000e+00)219; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], splat (float 2.000000e+00)220; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[X]], <2 x float> [[FADD]]221; CHECK-NEXT:    ret <2 x float> [[RETVAL]]222;223  %fcmp = fcmp une <2 x float> %y, <float 2.0, float 2.0>224  %fadd = fadd <2 x float> %x, %y225  %retval = select <2 x i1> %fcmp, <2 x float> %x, <2 x float> %fadd226  ret <2 x float> %retval227}228 229define <2 x float> @select_fcmp_fadd_ueq_nnan_not_zero_vec(<2 x float> %x, <2 x float> %y) {230; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_ueq_nnan_not_zero_vec(231; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {232; CHECK-NEXT:    [[FCMP:%.*]] = fcmp nnan ueq <2 x float> [[Y]], splat (float 2.000000e+00)233; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], splat (float 2.000000e+00)234; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[FADD]], <2 x float> [[X]]235; CHECK-NEXT:    ret <2 x float> [[RETVAL]]236;237  %fcmp = fcmp nnan ueq <2 x float> %y, <float 2.0, float 2.0>238  %fadd = fadd <2 x float> %x, %y239  %retval = select <2 x i1> %fcmp, <2 x float> %fadd, <2 x float> %x240  ret <2 x float> %retval241}242 243define <2 x float> @select_fcmp_fadd_one_nnan_not_zero_vec(<2 x float> %x, <2 x float> %y) {244; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_one_nnan_not_zero_vec(245; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {246; CHECK-NEXT:    [[FCMP:%.*]] = fcmp nnan one <2 x float> [[Y]], splat (float 2.000000e+00)247; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], splat (float 2.000000e+00)248; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[X]], <2 x float> [[FADD]]249; CHECK-NEXT:    ret <2 x float> [[RETVAL]]250;251  %fcmp = fcmp nnan one <2 x float> %y, <float 2.0, float 2.0>252  %fadd = fadd <2 x float> %x, %y253  %retval = select <2 x i1> %fcmp, <2 x float> %x, <2 x float> %fadd254  ret <2 x float> %retval255}256 257define <2 x float> @select_fcmp_fadd_ueq_vec(<2 x float> %x, <2 x float> %y) {258; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_ueq_vec(259; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {260; CHECK-NEXT:    [[FCMP:%.*]] = fcmp ueq <2 x float> [[Y]], splat (float 2.000000e+00)261; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], [[Y]]262; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[FADD]], <2 x float> [[X]]263; CHECK-NEXT:    ret <2 x float> [[RETVAL]]264;265  %fcmp = fcmp ueq <2 x float> %y, <float 2.0, float 2.0>266  %fadd = fadd <2 x float> %x, %y267  %retval = select <2 x i1> %fcmp, <2 x float> %fadd, <2 x float> %x268  ret <2 x float> %retval269}270 271define <2 x float> @select_fcmp_fadd_one_vec(<2 x float> %x, <2 x float> %y) {272; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_one_vec(273; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {274; CHECK-NEXT:    [[FCMP:%.*]] = fcmp one <2 x float> [[Y]], splat (float 2.000000e+00)275; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], [[Y]]276; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[X]], <2 x float> [[FADD]]277; CHECK-NEXT:    ret <2 x float> [[RETVAL]]278;279  %fcmp = fcmp one <2 x float> %y, <float 2.0, float 2.0>280  %fadd = fadd <2 x float> %x, %y281  %retval = select <2 x i1> %fcmp, <2 x float> %x, <2 x float> %fadd282  ret <2 x float> %retval283}284 285define <2 x float> @select_fcmp_fadd_oeq_zero_vec(<2 x float> %x, <2 x float> %y) {286; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_oeq_zero_vec(287; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {288; CHECK-NEXT:    [[FCMP:%.*]] = fcmp oeq <2 x float> [[Y]], zeroinitializer289; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], [[Y]]290; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[FADD]], <2 x float> [[X]]291; CHECK-NEXT:    ret <2 x float> [[RETVAL]]292;293  %fcmp = fcmp oeq <2 x float> %y, zeroinitializer294  %fadd = fadd <2 x float> %x, %y295  %retval = select <2 x i1> %fcmp, <2 x float> %fadd, <2 x float> %x296  ret <2 x float> %retval297}298 299define <2 x float> @select_fcmp_fadd_une_zero_vec(<2 x float> %x, <2 x float> %y) {300; CHECK-LABEL: define <2 x float> @select_fcmp_fadd_une_zero_vec(301; CHECK-SAME: <2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) {302; CHECK-NEXT:    [[FCMP:%.*]] = fcmp une <2 x float> [[Y]], zeroinitializer303; CHECK-NEXT:    [[FADD:%.*]] = fadd <2 x float> [[X]], [[Y]]304; CHECK-NEXT:    [[RETVAL:%.*]] = select <2 x i1> [[FCMP]], <2 x float> [[X]], <2 x float> [[FADD]]305; CHECK-NEXT:    ret <2 x float> [[RETVAL]]306;307  %fcmp = fcmp une <2 x float> %y, zeroinitializer308  %fadd = fadd <2 x float> %x, %y309  %retval = select <2 x i1> %fcmp, <2 x float> %x, <2 x float> %fadd310  ret <2 x float> %retval311}312 313define <2 x i8> @select_vec_op_const_no_undef(<2 x i8> %x) {314; CHECK-LABEL: define <2 x i8> @select_vec_op_const_no_undef(315; CHECK-SAME: <2 x i8> [[X:%.*]]) {316; CHECK-NEXT:    [[XZ:%.*]] = icmp eq <2 x i8> [[X]], <i8 1, i8 2>317; CHECK-NEXT:    [[XR:%.*]] = select <2 x i1> [[XZ]], <2 x i8> <i8 1, i8 2>, <2 x i8> <i8 4, i8 3>318; CHECK-NEXT:    ret <2 x i8> [[XR]]319;320  %xz = icmp eq <2 x i8> %x, <i8 1, i8 2>321  %xr = select <2 x i1> %xz, <2 x i8> %x, <2 x i8> <i8 4, i8 3>322  ret <2 x i8> %xr323}324 325define <2 x i8> @select_vec_op_const_undef(<2 x i8> %x) {326; CHECK-LABEL: define <2 x i8> @select_vec_op_const_undef(327; CHECK-SAME: <2 x i8> [[X:%.*]]) {328; CHECK-NEXT:    [[XZ:%.*]] = icmp eq <2 x i8> [[X]], <i8 1, i8 undef>329; CHECK-NEXT:    [[XR:%.*]] = select <2 x i1> [[XZ]], <2 x i8> [[X]], <2 x i8> <i8 4, i8 3>330; CHECK-NEXT:    ret <2 x i8> [[XR]]331;332  %xz = icmp eq <2 x i8> %x, <i8 1, i8 undef>333  %xr = select <2 x i1> %xz, <2 x i8> %x, <2 x i8> <i8 4, i8 3>334  ret <2 x i8> %xr335}336