503 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=instcombine < %s | FileCheck %s3 4define i1 @fcmp_ord_and_uno(half %x, half %y) {5; CHECK-LABEL: @fcmp_ord_and_uno(6; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH00007; CHECK-NEXT: [[UNO:%.*]] = fcmp uno half [[X]], [[Y:%.*]]8; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UNO]]9; CHECK-NEXT: ret i1 [[AND]]10;11 %ord = fcmp ord half %x, 0.012 %uno = fcmp uno half %x, %y13 %and = and i1 %ord, %uno14 ret i1 %and15}16 17define i1 @fcmp_ord_and_ueq(half %x, half %y) {18; CHECK-LABEL: @fcmp_ord_and_ueq(19; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000020; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y:%.*]]21; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]22; CHECK-NEXT: ret i1 [[AND]]23;24 %ord = fcmp ord half %x, 0.025 %ueq = fcmp ueq half %x, %y26 %and = and i1 %ord, %ueq27 ret i1 %and28}29 30define i1 @fcmp_ord_and_ugt(half %x, half %y) {31; CHECK-LABEL: @fcmp_ord_and_ugt(32; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000033; CHECK-NEXT: [[UGT:%.*]] = fcmp ugt half [[X]], [[Y:%.*]]34; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UGT]]35; CHECK-NEXT: ret i1 [[AND]]36;37 %ord = fcmp ord half %x, 0.038 %ugt = fcmp ugt half %x, %y39 %and = and i1 %ord, %ugt40 ret i1 %and41}42 43define i1 @fcmp_ord_and_uge(half %x, half %y) {44; CHECK-LABEL: @fcmp_ord_and_uge(45; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000046; CHECK-NEXT: [[UGE:%.*]] = fcmp uge half [[X]], [[Y:%.*]]47; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UGE]]48; CHECK-NEXT: ret i1 [[AND]]49;50 %ord = fcmp ord half %x, 0.051 %uge = fcmp uge half %x, %y52 %and = and i1 %ord, %uge53 ret i1 %and54}55 56define i1 @fcmp_ord_and_ult(half %x, half %y) {57; CHECK-LABEL: @fcmp_ord_and_ult(58; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000059; CHECK-NEXT: [[ULT:%.*]] = fcmp ult half [[X]], [[Y:%.*]]60; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[ULT]]61; CHECK-NEXT: ret i1 [[AND]]62;63 %ord = fcmp ord half %x, 0.064 %ult = fcmp ult half %x, %y65 %and = and i1 %ord, %ult66 ret i1 %and67}68 69define i1 @fcmp_ord_and_ule(half %x, half %y) {70; CHECK-LABEL: @fcmp_ord_and_ule(71; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000072; CHECK-NEXT: [[ULE:%.*]] = fcmp ule half [[X]], [[Y:%.*]]73; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[ULE]]74; CHECK-NEXT: ret i1 [[AND]]75;76 %ord = fcmp ord half %x, 0.077 %ule = fcmp ule half %x, %y78 %and = and i1 %ord, %ule79 ret i1 %and80}81 82define i1 @fcmp_ord_and_une(half %x, half %y) {83; CHECK-LABEL: @fcmp_ord_and_une(84; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH000085; CHECK-NEXT: [[UNE:%.*]] = fcmp une half [[X]], [[Y:%.*]]86; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UNE]]87; CHECK-NEXT: ret i1 [[AND]]88;89 %ord = fcmp ord half %x, 0.090 %une = fcmp une half %x, %y91 %and = and i1 %ord, %une92 ret i1 %and93}94 95define i1 @fcmp_ord_and_true(half %x, half %y) {96; CHECK-LABEL: @fcmp_ord_and_true(97; CHECK-NEXT: [[UNE:%.*]] = fcmp une half [[X:%.*]], [[Y:%.*]]98; CHECK-NEXT: ret i1 [[UNE]]99;100 %ord = fcmp true half %x, 0.0101 %une = fcmp une half %x, %y102 %and = and i1 %ord, %une103 ret i1 %and104}105 106define <2 x i1> @fcmp_ord_and_ueq_vector(<2 x half> %x, <2 x half> %y) {107; CHECK-LABEL: @fcmp_ord_and_ueq_vector(108; CHECK-NEXT: [[ORD:%.*]] = fcmp ord <2 x half> [[X:%.*]], zeroinitializer109; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq <2 x half> [[X]], [[Y:%.*]]110; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[ORD]], [[UEQ]]111; CHECK-NEXT: ret <2 x i1> [[AND]]112;113 %ord = fcmp ord <2 x half> %x, zeroinitializer114 %ueq = fcmp ueq <2 x half> %x, %y115 %and = and <2 x i1> %ord, %ueq116 ret <2 x i1> %and117}118 119; Negative test120define i1 @fcmp_ord_and_ueq_different_value0(half %x, half %y, half %z) {121; CHECK-LABEL: @fcmp_ord_and_ueq_different_value0(122; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000123; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Z:%.*]], [[Y:%.*]]124; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]125; CHECK-NEXT: ret i1 [[AND]]126;127 %ord = fcmp ord half %x, 0.0128 %ueq = fcmp ueq half %z, %y129 %and = and i1 %ord, %ueq130 ret i1 %and131}132 133; Negative test134define i1 @fcmp_ord_and_ueq_different_value1(half %x, half %y, half %z) {135; CHECK-LABEL: @fcmp_ord_and_ueq_different_value1(136; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000137; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y:%.*]], [[Z:%.*]]138; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]139; CHECK-NEXT: ret i1 [[AND]]140;141 %ord = fcmp ord half %x, 0.0142 %ueq = fcmp ueq half %y, %z143 %and = and i1 %ord, %ueq144 ret i1 %and145}146 147declare half @foo()148 149define i1 @fcmp_ord_and_ueq_commute0() {150; CHECK-LABEL: @fcmp_ord_and_ueq_commute0(151; CHECK-NEXT: [[X:%.*]] = call half @foo()152; CHECK-NEXT: [[Y:%.*]] = call half @foo()153; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000154; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y]]155; CHECK-NEXT: [[AND:%.*]] = and i1 [[UEQ]], [[ORD]]156; CHECK-NEXT: ret i1 [[AND]]157;158 %x = call half @foo()159 %y = call half @foo()160 %ord = fcmp ord half %x, 0.0161 %ueq = fcmp ueq half %x, %y162 %and = and i1 %ueq, %ord163 ret i1 %and164}165 166define i1 @fcmp_ord_and_ueq_commute1() {167; CHECK-LABEL: @fcmp_ord_and_ueq_commute1(168; CHECK-NEXT: [[X:%.*]] = call half @foo()169; CHECK-NEXT: [[Y:%.*]] = call half @foo()170; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000171; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y]]172; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]173; CHECK-NEXT: ret i1 [[AND]]174;175 %x = call half @foo()176 %y = call half @foo()177 %ord = fcmp ord half %x, 0.0178 %ueq = fcmp ueq half %x, %y179 %and = and i1 %ord, %ueq180 ret i1 %and181}182 183define i1 @fcmp_oeq_x_x_and_ult(half %x, half %y) {184; CHECK-LABEL: @fcmp_oeq_x_x_and_ult(185; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000186; CHECK-NEXT: [[ULT:%.*]] = fcmp ult half [[X]], [[Y:%.*]]187; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[ULT]]188; CHECK-NEXT: ret i1 [[AND]]189;190 %ord = fcmp oeq half %x, %x ; noncanonical ordered191 %ult = fcmp ult half %x, %y192 %and = and i1 %ord, %ult193 ret i1 %and194}195 196define i1 @fcmp_ord_and_ueq_preserve_flags(half %x, half %y) {197; CHECK-LABEL: @fcmp_ord_and_ueq_preserve_flags(198; CHECK-NEXT: [[ORD:%.*]] = fcmp nsz ord half [[X:%.*]], 0xH0000199; CHECK-NEXT: [[UEQ:%.*]] = fcmp nsz ueq half [[X]], [[Y:%.*]]200; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]201; CHECK-NEXT: ret i1 [[AND]]202;203 %ord = fcmp nsz ord half %x, 0.0204 %ueq = fcmp nsz ueq half %x, %y205 %and = and i1 %ord, %ueq206 ret i1 %and207}208 209define i1 @fcmp_ord_and_ueq_preserve_subset_flags0(half %x, half %y) {210; CHECK-LABEL: @fcmp_ord_and_ueq_preserve_subset_flags0(211; CHECK-NEXT: [[ORD:%.*]] = fcmp nsz ord half [[X:%.*]], 0xH0000212; CHECK-NEXT: [[UEQ:%.*]] = fcmp ninf nsz ueq half [[X]], [[Y:%.*]]213; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]214; CHECK-NEXT: ret i1 [[AND]]215;216 %ord = fcmp nsz ord half %x, 0.0217 %ueq = fcmp ninf nsz ueq half %x, %y218 %and = and i1 %ord, %ueq219 ret i1 %and220}221 222define i1 @fcmp_ord_and_ueq_preserve_subset_flags1(half %x, half %y) {223; CHECK-LABEL: @fcmp_ord_and_ueq_preserve_subset_flags1(224; CHECK-NEXT: [[ORD:%.*]] = fcmp ninf nsz ord half [[X:%.*]], 0xH0000225; CHECK-NEXT: [[UEQ:%.*]] = fcmp nsz ueq half [[X]], [[Y:%.*]]226; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]227; CHECK-NEXT: ret i1 [[AND]]228;229 %ord = fcmp ninf nsz ord half %x, 0.0230 %ueq = fcmp nsz ueq half %x, %y231 %and = and i1 %ord, %ueq232 ret i1 %and233}234 235define i1 @fcmp_ord_and_ueq_flags_lhs(half %x, half %y) {236; CHECK-LABEL: @fcmp_ord_and_ueq_flags_lhs(237; CHECK-NEXT: [[ORD:%.*]] = fcmp nsz ord half [[X:%.*]], 0xH0000238; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y:%.*]]239; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]240; CHECK-NEXT: ret i1 [[AND]]241;242 %ord = fcmp nsz ord half %x, 0.0243 %ueq = fcmp ueq half %x, %y244 %and = and i1 %ord, %ueq245 ret i1 %and246}247 248define i1 @fcmp_ord_and_ueq_flags_rhs(half %x, half %y) {249; CHECK-LABEL: @fcmp_ord_and_ueq_flags_rhs(250; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000251; CHECK-NEXT: [[UEQ:%.*]] = fcmp nsz ueq half [[X]], [[Y:%.*]]252; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]253; CHECK-NEXT: ret i1 [[AND]]254;255 %ord = fcmp ord half %x, 0.0256 %ueq = fcmp nsz ueq half %x, %y257 %and = and i1 %ord, %ueq258 ret i1 %and259}260 261; Can ignore fabs and fneg262define i1 @fcmp_ord_and_fabs_ueq(half %x, half %y) {263; CHECK-LABEL: @fcmp_ord_and_fabs_ueq(264; CHECK-NEXT: [[FABS_X:%.*]] = call half @llvm.fabs.f16(half [[X:%.*]])265; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000266; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[FABS_X]], [[Y:%.*]]267; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]268; CHECK-NEXT: ret i1 [[AND]]269;270 %fabs.x = call half @llvm.fabs.f16(half %x)271 %ord = fcmp ord half %x, 0.0272 %ueq = fcmp ueq half %fabs.x, %y273 %and = and i1 %ord, %ueq274 ret i1 %and275}276 277define i1 @fcmp_ord_fabs_and_ueq(half %x, half %y) {278; CHECK-LABEL: @fcmp_ord_fabs_and_ueq(279; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000280; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y:%.*]]281; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]282; CHECK-NEXT: ret i1 [[AND]]283;284 %fabs.x = call half @llvm.fabs.f16(half %x)285 %ord = fcmp ord half %fabs.x, 0.0286 %ueq = fcmp ueq half %x, %y287 %and = and i1 %ord, %ueq288 ret i1 %and289}290 291define i1 @fcmp_ord_and_fabs_ueq_commute0() {292; CHECK-LABEL: @fcmp_ord_and_fabs_ueq_commute0(293; CHECK-NEXT: [[X:%.*]] = call half @foo()294; CHECK-NEXT: [[Y:%.*]] = call half @foo()295; CHECK-NEXT: [[FABS_X:%.*]] = call half @llvm.fabs.f16(half [[X]])296; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000297; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y]], [[FABS_X]]298; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]299; CHECK-NEXT: ret i1 [[AND]]300;301 %x = call half @foo()302 %y = call half @foo()303 %fabs.x = call half @llvm.fabs.f16(half %x)304 %ord = fcmp ord half %x, 0.0305 %ueq = fcmp ueq half %y, %fabs.x306 %and = and i1 %ord, %ueq307 ret i1 %and308}309 310define i1 @fcmp_ord_and_fabs_ueq_commute1() {311; CHECK-LABEL: @fcmp_ord_and_fabs_ueq_commute1(312; CHECK-NEXT: [[X:%.*]] = call half @foo()313; CHECK-NEXT: [[Y:%.*]] = call half @foo()314; CHECK-NEXT: [[FABS_X:%.*]] = call half @llvm.fabs.f16(half [[X]])315; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000316; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y]], [[FABS_X]]317; CHECK-NEXT: [[AND:%.*]] = and i1 [[UEQ]], [[ORD]]318; CHECK-NEXT: ret i1 [[AND]]319;320 %x = call half @foo()321 %y = call half @foo()322 %fabs.x = call half @llvm.fabs.f16(half %x)323 %ord = fcmp ord half %x, 0.0324 %ueq = fcmp ueq half %y, %fabs.x325 %and = and i1 %ueq, %ord326 ret i1 %and327}328 329define <2 x i1> @fcmp_ord_and_fabs_ueq_vector(<2 x half> %x, <2 x half> %y) {330; CHECK-LABEL: @fcmp_ord_and_fabs_ueq_vector(331; CHECK-NEXT: [[FABS_X:%.*]] = call <2 x half> @llvm.fabs.v2f16(<2 x half> [[X:%.*]])332; CHECK-NEXT: [[ORD:%.*]] = fcmp ord <2 x half> [[X]], zeroinitializer333; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq <2 x half> [[FABS_X]], [[Y:%.*]]334; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[ORD]], [[UEQ]]335; CHECK-NEXT: ret <2 x i1> [[AND]]336;337 %fabs.x = call <2 x half> @llvm.fabs.v2f16(<2 x half> %x)338 %ord = fcmp ord <2 x half> %x, zeroinitializer339 %ueq = fcmp ueq <2 x half> %fabs.x, %y340 %and = and <2 x i1> %ord, %ueq341 ret <2 x i1> %and342}343 344define i1 @fcmp_ord_fabs_and_fabs_ueq(half %x, half %y) {345; CHECK-LABEL: @fcmp_ord_fabs_and_fabs_ueq(346; CHECK-NEXT: [[FABS_X:%.*]] = call half @llvm.fabs.f16(half [[X:%.*]])347; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000348; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[FABS_X]], [[Y:%.*]]349; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]350; CHECK-NEXT: ret i1 [[AND]]351;352 %fabs.x = call half @llvm.fabs.f16(half %x)353 %ord = fcmp ord half %fabs.x, 0.0354 %ueq = fcmp ueq half %fabs.x, %y355 %and = and i1 %ord, %ueq356 ret i1 %and357}358 359define i1 @fcmp_ord_and_fneg_ueq(half %x, half %y) {360; CHECK-LABEL: @fcmp_ord_and_fneg_ueq(361; CHECK-NEXT: [[FNEG_X:%.*]] = fneg half [[X:%.*]]362; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000363; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y:%.*]], [[FNEG_X]]364; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]365; CHECK-NEXT: ret i1 [[AND]]366;367 %fneg.x = fneg half %x368 %ord = fcmp ord half %x, 0.0369 %ueq = fcmp ueq half %fneg.x, %y370 %and = and i1 %ord, %ueq371 ret i1 %and372}373 374define i1 @fcmp_ord_fneg_and_ueq(half %x, half %y) {375; CHECK-LABEL: @fcmp_ord_fneg_and_ueq(376; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X:%.*]], 0xH0000377; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y:%.*]]378; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]379; CHECK-NEXT: ret i1 [[AND]]380;381 %fneg.x = fneg half %x382 %ord = fcmp ord half %fneg.x, 0.0383 %ueq = fcmp ueq half %x, %y384 %and = and i1 %ord, %ueq385 ret i1 %and386}387 388define i1 @fcmp_ord_fneg_and_fneg_ueq(half %x, half %y) {389; CHECK-LABEL: @fcmp_ord_fneg_and_fneg_ueq(390; CHECK-NEXT: [[FNEG_X:%.*]] = fneg half [[X:%.*]]391; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000392; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y:%.*]], [[FNEG_X]]393; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]394; CHECK-NEXT: ret i1 [[AND]]395;396 %fneg.x = fneg half %x397 %ord = fcmp ord half %fneg.x, 0.0398 %ueq = fcmp ueq half %fneg.x, %y399 %and = and i1 %ord, %ueq400 ret i1 %and401}402 403define i1 @fcmp_ord_and_fneg_fabs_ueq(half %x, half %y) {404; CHECK-LABEL: @fcmp_ord_and_fneg_fabs_ueq(405; CHECK-NEXT: [[FABS_X:%.*]] = call half @llvm.fabs.f16(half [[X:%.*]])406; CHECK-NEXT: [[FNEG_FABS_X:%.*]] = fneg half [[FABS_X]]407; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000408; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y:%.*]], [[FNEG_FABS_X]]409; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]410; CHECK-NEXT: ret i1 [[AND]]411;412 %fabs.x = call half @llvm.fabs.f16(half %x)413 %fneg.fabs.x = fneg half %fabs.x414 %ord = fcmp ord half %x, 0.0415 %ueq = fcmp ueq half %fneg.fabs.x, %y416 %and = and i1 %ord, %ueq417 ret i1 %and418}419 420define i1 @fcmp_ord_and_copysign_ueq(half %x, half %y, half %z) {421; CHECK-LABEL: @fcmp_ord_and_copysign_ueq(422; CHECK-NEXT: [[COPYSIGN_X_Y:%.*]] = call half @llvm.copysign.f16(half [[X:%.*]], half [[Z:%.*]])423; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000424; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[COPYSIGN_X_Y]], [[Y:%.*]]425; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]426; CHECK-NEXT: ret i1 [[AND]]427;428 %copysign.x.y = call half @llvm.copysign.f16(half %x, half %z)429 %ord = fcmp ord half %x, 0.0430 %ueq = fcmp ueq half %copysign.x.y, %y431 %and = and i1 %ord, %ueq432 ret i1 %and433}434 435define i1 @fcmp_copysign_ord_and_ueq(half %x, half %y, half %z) {436; CHECK-LABEL: @fcmp_copysign_ord_and_ueq(437; CHECK-NEXT: [[COPYSIGN_X_Y:%.*]] = call half @llvm.copysign.f16(half [[X:%.*]], half [[Z:%.*]])438; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[COPYSIGN_X_Y]], 0xH0000439; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[X]], [[Y:%.*]]440; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]441; CHECK-NEXT: ret i1 [[AND]]442;443 %copysign.x.y = call half @llvm.copysign.f16(half %x, half %z)444 %ord = fcmp ord half %copysign.x.y, 0.0445 %ueq = fcmp ueq half %x, %y446 %and = and i1 %ord, %ueq447 ret i1 %and448}449 450define i1 @fcmp_ord_and_copysign_ueq_commute(half %x, half %y, half %z) {451; CHECK-LABEL: @fcmp_ord_and_copysign_ueq_commute(452; CHECK-NEXT: [[COPYSIGN_X_Y:%.*]] = call half @llvm.copysign.f16(half [[X:%.*]], half [[Z:%.*]])453; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000454; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[Y:%.*]], [[COPYSIGN_X_Y]]455; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]456; CHECK-NEXT: ret i1 [[AND]]457;458 %copysign.x.y = call half @llvm.copysign.f16(half %x, half %z)459 %ord = fcmp ord half %x, 0.0460 %ueq = fcmp ueq half %y, %copysign.x.y461 %and = and i1 %ord, %ueq462 ret i1 %and463}464 465define i1 @fcmp_ord_and_copysign_fneg_ueq(half %x, half %y, half %z) {466; CHECK-LABEL: @fcmp_ord_and_copysign_fneg_ueq(467; CHECK-NEXT: [[COPYSIGN_X_Y:%.*]] = call half @llvm.copysign.f16(half [[X:%.*]], half [[Z:%.*]])468; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000469; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[COPYSIGN_X_Y]], [[Y:%.*]]470; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]471; CHECK-NEXT: ret i1 [[AND]]472;473 %x.fneg = fneg half %x474 %copysign.x.y = call half @llvm.copysign.f16(half %x.fneg, half %z)475 %ord = fcmp ord half %x, 0.0476 %ueq = fcmp ueq half %copysign.x.y, %y477 %and = and i1 %ord, %ueq478 ret i1 %and479}480 481define i1 @fcmp_ord_and_fneg_copysign_ueq(half %x, half %y, half %z) {482; CHECK-LABEL: @fcmp_ord_and_fneg_copysign_ueq(483; CHECK-NEXT: [[TMP1:%.*]] = fneg half [[Z:%.*]]484; CHECK-NEXT: [[FNEG_COPYSIGN:%.*]] = call half @llvm.copysign.f16(half [[X:%.*]], half [[TMP1]])485; CHECK-NEXT: [[ORD:%.*]] = fcmp ord half [[X]], 0xH0000486; CHECK-NEXT: [[UEQ:%.*]] = fcmp ueq half [[FNEG_COPYSIGN]], [[Y:%.*]]487; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD]], [[UEQ]]488; CHECK-NEXT: ret i1 [[AND]]489;490 %copysign.x.y = call half @llvm.copysign.f16(half %x, half %z)491 %fneg.copysign = fneg half %copysign.x.y492 %ord = fcmp ord half %x, 0.0493 %ueq = fcmp ueq half %fneg.copysign, %y494 %and = and i1 %ord, %ueq495 ret i1 %and496}497 498 499declare half @llvm.fabs.f16(half)500declare <2 x half> @llvm.fabs.v2f16(<2 x half>)501declare half @llvm.copysign.f16(half, half)502declare <2 x half> @llvm.copysign.v2f16(<2 x half>, <2 x half>)503