1364 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals2; RUN: opt -S -passes=instcombine < %s | FileCheck %s3 4declare void @use(i1)5declare i1 @gen_i1()6declare <2 x i1> @gen_v2i1()7 8; Should not be converted to "and", which has different poison semantics.9;.10; CHECK: @g1 = external global i1611; CHECK: @g2 = external global i1612;.13define i1 @logical_and(i1 %a, i1 %b) {14; CHECK-LABEL: @logical_and(15; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 [[B:%.*]], i1 false16; CHECK-NEXT: ret i1 [[RES]]17;18 %res = select i1 %a, i1 %b, i1 false19 ret i1 %res20}21 22; Should not be converted to "or", which has different poison semantics.23define i1 @logical_or(i1 %a, i1 %b) {24; CHECK-LABEL: @logical_or(25; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[B:%.*]]26; CHECK-NEXT: ret i1 [[RES]]27;28 %res = select i1 %a, i1 true, i1 %b29 ret i1 %res30}31; Canonicalize to logical and form, even if that requires adding a "not".32define i1 @logical_and_not(i1 %a, i1 %b) {33; CHECK-LABEL: @logical_and_not(34; CHECK-NEXT: [[NOT_A:%.*]] = xor i1 [[A:%.*]], true35; CHECK-NEXT: [[RES:%.*]] = select i1 [[NOT_A]], i1 [[B:%.*]], i1 false36; CHECK-NEXT: ret i1 [[RES]]37;38 %res = select i1 %a, i1 false, i1 %b39 ret i1 %res40}41 42; Canonicalize to logical or form, even if that requires adding a "not".43define i1 @logical_or_not(i1 %a, i1 %b) {44; CHECK-LABEL: @logical_or_not(45; CHECK-NEXT: [[NOT_A:%.*]] = xor i1 [[A:%.*]], true46; CHECK-NEXT: [[RES:%.*]] = select i1 [[NOT_A]], i1 true, i1 [[B:%.*]]47; CHECK-NEXT: ret i1 [[RES]]48;49 %res = select i1 %a, i1 %b, i1 true50 ret i1 %res51}52 53; These are variants where condition or !condition is used to represent true54; or false in one of the select arms. It should be canonicalized to the55; constants.56 57define i1 @logical_and_cond_reuse(i1 %a, i1 %b) {58; CHECK-LABEL: @logical_and_cond_reuse(59; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 [[B:%.*]], i1 false60; CHECK-NEXT: ret i1 [[RES]]61;62 %res = select i1 %a, i1 %b, i1 %a63 ret i1 %res64}65 66define i1 @logical_or_cond_reuse(i1 %a, i1 %b) {67; CHECK-LABEL: @logical_or_cond_reuse(68; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[B:%.*]]69; CHECK-NEXT: ret i1 [[RES]]70;71 %res = select i1 %a, i1 %a, i1 %b72 ret i1 %res73}74 75define i1 @logical_and_not_cond_reuse(i1 %a, i1 %b) {76; CHECK-LABEL: @logical_and_not_cond_reuse(77; CHECK-NEXT: [[NOT_A:%.*]] = xor i1 [[A:%.*]], true78; CHECK-NEXT: [[RES:%.*]] = select i1 [[NOT_A]], i1 true, i1 [[B:%.*]]79; CHECK-NEXT: ret i1 [[RES]]80;81 %a.not = xor i1 %a, true82 %res = select i1 %a, i1 %b, i1 %a.not83 ret i1 %res84}85 86define i1 @logical_or_not_cond_reuse(i1 %a, i1 %b) {87; CHECK-LABEL: @logical_or_not_cond_reuse(88; CHECK-NEXT: [[NOT_A:%.*]] = xor i1 [[A:%.*]], true89; CHECK-NEXT: [[RES:%.*]] = select i1 [[NOT_A]], i1 [[B:%.*]], i1 false90; CHECK-NEXT: ret i1 [[RES]]91;92 %a.not = xor i1 %a, true93 %res = select i1 %a, i1 %a.not, i1 %b94 ret i1 %res95}96 97; Safe to convert to or due to poison implication.98define i1 @logical_or_implies(i32 %x) {99; CHECK-LABEL: @logical_or_implies(100; CHECK-NEXT: [[C1:%.*]] = icmp eq i32 [[X:%.*]], 0101; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[X]], 42102; CHECK-NEXT: [[RES:%.*]] = or i1 [[C1]], [[C2]]103; CHECK-NEXT: ret i1 [[RES]]104;105 %c1 = icmp eq i32 %x, 0106 %c2 = icmp eq i32 %x, 42107 %res = select i1 %c1, i1 true, i1 %c2108 ret i1 %res109}110 111; Safe to convert to or due to poison implication.112define <vscale x 2 x i1> @logical_or_implies_scalablevec(<vscale x 2 x i32> %x) {113; CHECK-LABEL: @logical_or_implies_scalablevec(114; CHECK-NEXT: [[C1:%.*]] = icmp eq <vscale x 2 x i32> [[X:%.*]], zeroinitializer115; CHECK-NEXT: [[C2:%.*]] = icmp eq <vscale x 2 x i32> [[X]], splat (i32 42)116; CHECK-NEXT: [[RES:%.*]] = or <vscale x 2 x i1> [[C1]], [[C2]]117; CHECK-NEXT: ret <vscale x 2 x i1> [[RES]]118;119 %c1 = icmp eq <vscale x 2 x i32> %x, zeroinitializer120 %c2 = icmp eq <vscale x 2 x i32> %x, splat (i32 42)121 %res = select <vscale x 2 x i1> %c1, <vscale x 2 x i1> splat (i1 true), <vscale x 2 x i1> %c2122 ret <vscale x 2 x i1> %res123}124 125; Will fold after conversion to or.126define i1 @logical_or_implies_folds(i32 %x) {127; CHECK-LABEL: @logical_or_implies_folds(128; CHECK-NEXT: ret i1 true129;130 %c1 = icmp slt i32 %x, 0131 %c2 = icmp sge i32 %x, 0132 %res = select i1 %c1, i1 true, i1 %c2133 ret i1 %res134}135 136; Safe to convert to and due to poison implication.137define i1 @logical_and_implies(i32 %x) {138; CHECK-LABEL: @logical_and_implies(139; CHECK-NEXT: [[C1:%.*]] = icmp ne i32 [[X:%.*]], 0140; CHECK-NEXT: [[C2:%.*]] = icmp ne i32 [[X]], 42141; CHECK-NEXT: [[RES:%.*]] = and i1 [[C1]], [[C2]]142; CHECK-NEXT: ret i1 [[RES]]143;144 %c1 = icmp ne i32 %x, 0145 %c2 = icmp ne i32 %x, 42146 %res = select i1 %c1, i1 %c2, i1 false147 ret i1 %res148}149 150; Safe to convert to and due to poison implication.151define <vscale x 2 x i1> @logical_and_implies_scalablevec(<vscale x 2 x i32> %x) {152; CHECK-LABEL: @logical_and_implies_scalablevec(153; CHECK-NEXT: [[C1:%.*]] = icmp ne <vscale x 2 x i32> [[X:%.*]], zeroinitializer154; CHECK-NEXT: [[C2:%.*]] = icmp ne <vscale x 2 x i32> [[X]], splat (i32 42)155; CHECK-NEXT: [[RES:%.*]] = and <vscale x 2 x i1> [[C1]], [[C2]]156; CHECK-NEXT: ret <vscale x 2 x i1> [[RES]]157;158 %c1 = icmp ne <vscale x 2 x i32> %x, zeroinitializer159 %c2 = icmp ne <vscale x 2 x i32> %x, splat (i32 42)160 %res = select <vscale x 2 x i1> %c1, <vscale x 2 x i1> %c2, <vscale x 2 x i1> zeroinitializer161 ret <vscale x 2 x i1> %res162}163 164; Will fold after conversion to and.165define i1 @logical_and_implies_folds(i32 %x) {166; CHECK-LABEL: @logical_and_implies_folds(167; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[X:%.*]], 42168; CHECK-NEXT: ret i1 [[C1]]169;170 %c1 = icmp ugt i32 %x, 42171 %c2 = icmp ne i32 %x, 0172 %res = select i1 %c1, i1 %c2, i1 false173 ret i1 %res174}175 176; Noundef on condition has no effect.177define i1 @logical_or_noundef_a(i1 noundef %a, i1 %b) {178; CHECK-LABEL: @logical_or_noundef_a(179; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[B:%.*]]180; CHECK-NEXT: ret i1 [[RES]]181;182 %res = select i1 %a, i1 true, i1 %b183 ret i1 %res184}185 186; Noundef on false value allows conversion to or.187define i1 @logical_or_noundef_b(i1 %a, i1 noundef %b) {188; CHECK-LABEL: @logical_or_noundef_b(189; CHECK-NEXT: [[RES:%.*]] = or i1 [[A:%.*]], [[B:%.*]]190; CHECK-NEXT: ret i1 [[RES]]191;192 %res = select i1 %a, i1 true, i1 %b193 ret i1 %res194}195 196; Noundef on condition has no effect.197define i1 @logical_and_noundef_a(i1 noundef %a, i1 %b) {198; CHECK-LABEL: @logical_and_noundef_a(199; CHECK-NEXT: [[RES:%.*]] = select i1 [[A:%.*]], i1 [[B:%.*]], i1 false200; CHECK-NEXT: ret i1 [[RES]]201;202 %res = select i1 %a, i1 %b, i1 false203 ret i1 %res204}205 206; Noundef on false value allows conversion to and.207define i1 @logical_and_noundef_b(i1 %a, i1 noundef %b) {208; CHECK-LABEL: @logical_and_noundef_b(209; CHECK-NEXT: [[RES:%.*]] = and i1 [[A:%.*]], [[B:%.*]]210; CHECK-NEXT: ret i1 [[RES]]211;212 %res = select i1 %a, i1 %b, i1 false213 ret i1 %res214}215 216; (!x && !y) || x --> x || !y217 218define i1 @not_not_true(i1 %x, i1 %y) {219; CHECK-LABEL: @not_not_true(220; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true221; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[NOTY]]222; CHECK-NEXT: ret i1 [[R]]223;224 %notx = xor i1 %x, true225 %noty = xor i1 %y, true226 %r = select i1 %notx, i1 %noty, i1 true227 ret i1 %r228}229 230; (!x && !y) --> !(x || y)231 232define i1 @not_not_false(i1 %x, i1 %y) !prof !0 {233; CHECK-LABEL: @not_not_false(234; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[Y:%.*]], !prof [[PROF1:![0-9]+]]235; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true236; CHECK-NEXT: ret i1 [[R]]237;238 %notx = xor i1 %x, true239 %noty = xor i1 %y, true240 %r = select i1 %notx, i1 %noty, i1 false, !prof !1241 ret i1 %r242}243 244; (!x || !y) --> !(x && y)245 246define i1 @not_true_not(i1 %x, i1 %y) !prof !0 {247; CHECK-LABEL: @not_true_not(248; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 false, !prof [[PROF1]]249; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true250; CHECK-NEXT: ret i1 [[R]]251;252 %notx = xor i1 %x, true253 %noty = xor i1 %y, true254 %r = select i1 %notx, i1 true, i1 %noty, !prof !1255 ret i1 %r256}257 258; (!!x && !y) --> x && !y259 260define i1 @not_false_not(i1 %x, i1 %y) {261; CHECK-LABEL: @not_false_not(262; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true263; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 [[NOTY]], i1 false264; CHECK-NEXT: ret i1 [[R]]265;266 %notx = xor i1 %x, true267 %noty = xor i1 %y, true268 %r = select i1 %notx, i1 false, i1 %noty269 ret i1 %r270}271 272define i1 @not_not_true_use1(i1 %x, i1 %y) {273; CHECK-LABEL: @not_not_true_use1(274; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true275; CHECK-NEXT: call void @use(i1 [[NOTX]])276; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true277; CHECK-NEXT: [[R:%.*]] = select i1 [[X]], i1 true, i1 [[NOTY]]278; CHECK-NEXT: ret i1 [[R]]279;280 %notx = xor i1 %x, true281 call void @use(i1 %notx)282 %noty = xor i1 %y, true283 %r = select i1 %notx, i1 %noty, i1 true284 ret i1 %r285}286 287define i1 @not_not_false_use1(i1 %x, i1 %y) {288; CHECK-LABEL: @not_not_false_use1(289; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true290; CHECK-NEXT: call void @use(i1 [[NOTX]])291; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X]], i1 true, i1 [[Y:%.*]]292; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true293; CHECK-NEXT: ret i1 [[R]]294;295 %notx = xor i1 %x, true296 call void @use(i1 %notx)297 %noty = xor i1 %y, true298 %r = select i1 %notx, i1 %noty, i1 false299 ret i1 %r300}301 302define i1 @not_true_not_use1(i1 %x, i1 %y) {303; CHECK-LABEL: @not_true_not_use1(304; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true305; CHECK-NEXT: call void @use(i1 [[NOTX]])306; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X]], i1 [[Y:%.*]], i1 false307; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true308; CHECK-NEXT: ret i1 [[R]]309;310 %notx = xor i1 %x, true311 call void @use(i1 %notx)312 %noty = xor i1 %y, true313 %r = select i1 %notx, i1 true, i1 %noty314 ret i1 %r315}316 317define i1 @not_false_not_use1(i1 %x, i1 %y) {318; CHECK-LABEL: @not_false_not_use1(319; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true320; CHECK-NEXT: call void @use(i1 [[NOTX]])321; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true322; CHECK-NEXT: [[R:%.*]] = select i1 [[X]], i1 [[NOTY]], i1 false323; CHECK-NEXT: ret i1 [[R]]324;325 %notx = xor i1 %x, true326 call void @use(i1 %notx)327 %noty = xor i1 %y, true328 %r = select i1 %notx, i1 false, i1 %noty329 ret i1 %r330}331 332define i1 @not_not_true_use2(i1 %x, i1 %y) {333; CHECK-LABEL: @not_not_true_use2(334; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true335; CHECK-NEXT: call void @use(i1 [[NOTY]])336; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[NOTY]]337; CHECK-NEXT: ret i1 [[R]]338;339 %notx = xor i1 %x, true340 %noty = xor i1 %y, true341 call void @use(i1 %noty)342 %r = select i1 %notx, i1 %noty, i1 true343 ret i1 %r344}345 346define i1 @not_not_false_use2(i1 %x, i1 %y) {347; CHECK-LABEL: @not_not_false_use2(348; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true349; CHECK-NEXT: call void @use(i1 [[NOTY]])350; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[Y]]351; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true352; CHECK-NEXT: ret i1 [[R]]353;354 %notx = xor i1 %x, true355 %noty = xor i1 %y, true356 call void @use(i1 %noty)357 %r = select i1 %notx, i1 %noty, i1 false358 ret i1 %r359}360 361define i1 @not_true_not_use2(i1 %x, i1 %y) {362; CHECK-LABEL: @not_true_not_use2(363; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true364; CHECK-NEXT: call void @use(i1 [[NOTY]])365; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[X:%.*]], i1 [[Y]], i1 false366; CHECK-NEXT: [[R:%.*]] = xor i1 [[TMP1]], true367; CHECK-NEXT: ret i1 [[R]]368;369 %notx = xor i1 %x, true370 %noty = xor i1 %y, true371 call void @use(i1 %noty)372 %r = select i1 %notx, i1 true, i1 %noty373 ret i1 %r374}375 376define i1 @not_false_not_use2(i1 %x, i1 %y) {377; CHECK-LABEL: @not_false_not_use2(378; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true379; CHECK-NEXT: call void @use(i1 [[NOTY]])380; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 [[NOTY]], i1 false381; CHECK-NEXT: ret i1 [[R]]382;383 %notx = xor i1 %x, true384 %noty = xor i1 %y, true385 call void @use(i1 %noty)386 %r = select i1 %notx, i1 false, i1 %noty387 ret i1 %r388}389 390define i1 @not_not_true_use3(i1 %x, i1 %y) {391; CHECK-LABEL: @not_not_true_use3(392; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true393; CHECK-NEXT: call void @use(i1 [[NOTX]])394; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true395; CHECK-NEXT: call void @use(i1 [[NOTY]])396; CHECK-NEXT: [[R:%.*]] = select i1 [[X]], i1 true, i1 [[NOTY]]397; CHECK-NEXT: ret i1 [[R]]398;399 %notx = xor i1 %x, true400 call void @use(i1 %notx)401 %noty = xor i1 %y, true402 call void @use(i1 %noty)403 %r = select i1 %notx, i1 %noty, i1 true404 ret i1 %r405}406 407define i1 @not_not_false_use3(i1 %x, i1 %y) {408; CHECK-LABEL: @not_not_false_use3(409; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true410; CHECK-NEXT: call void @use(i1 [[NOTX]])411; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true412; CHECK-NEXT: call void @use(i1 [[NOTY]])413; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTX]], i1 [[NOTY]], i1 false414; CHECK-NEXT: ret i1 [[R]]415;416 %notx = xor i1 %x, true417 call void @use(i1 %notx)418 %noty = xor i1 %y, true419 call void @use(i1 %noty)420 %r = select i1 %notx, i1 %noty, i1 false421 ret i1 %r422}423 424define i1 @not_true_not_use3(i1 %x, i1 %y) {425; CHECK-LABEL: @not_true_not_use3(426; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true427; CHECK-NEXT: call void @use(i1 [[NOTX]])428; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true429; CHECK-NEXT: call void @use(i1 [[NOTY]])430; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTX]], i1 true, i1 [[NOTY]]431; CHECK-NEXT: ret i1 [[R]]432;433 %notx = xor i1 %x, true434 call void @use(i1 %notx)435 %noty = xor i1 %y, true436 call void @use(i1 %noty)437 %r = select i1 %notx, i1 true, i1 %noty438 ret i1 %r439}440 441define i1 @not_false_not_use3(i1 %x, i1 %y) {442; CHECK-LABEL: @not_false_not_use3(443; CHECK-NEXT: [[NOTX:%.*]] = xor i1 [[X:%.*]], true444; CHECK-NEXT: call void @use(i1 [[NOTX]])445; CHECK-NEXT: [[NOTY:%.*]] = xor i1 [[Y:%.*]], true446; CHECK-NEXT: call void @use(i1 [[NOTY]])447; CHECK-NEXT: [[R:%.*]] = select i1 [[X]], i1 [[NOTY]], i1 false448; CHECK-NEXT: ret i1 [[R]]449;450 %notx = xor i1 %x, true451 call void @use(i1 %notx)452 %noty = xor i1 %y, true453 call void @use(i1 %noty)454 %r = select i1 %notx, i1 false, i1 %noty455 ret i1 %r456}457 458; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35399459 460@g1 = external global i16461@g2 = external global i16462 463define i1 @demorgan_select_infloop1(i1 %L) {464; CHECK-LABEL: @demorgan_select_infloop1(465; CHECK-NEXT: [[NOT_L:%.*]] = xor i1 [[L:%.*]], true466; CHECK-NEXT: ret i1 [[NOT_L]]467;468 %not.L = xor i1 %L, true469 %cmp = icmp eq ptr getelementptr inbounds (i16, ptr @g2, i64 1), @g1470 %add = add i1 %cmp, %cmp471 %xor = xor i1 %add, true472 %C15 = select i1 %not.L, i1 %xor, i1 false473 ret i1 %C15474}475 476 477define i1 @demorgan_select_infloop2(i1 %L) {478; CHECK-LABEL: @demorgan_select_infloop2(479; CHECK-NEXT: [[NOT_L:%.*]] = xor i1 [[L:%.*]], true480; CHECK-NEXT: [[CMP2:%.*]] = icmp ne ptr getelementptr inbounds nuw (i8, ptr @g2, i64 2), @g1481; CHECK-NEXT: [[C15:%.*]] = select i1 [[NOT_L]], i1 [[CMP2]], i1 false482; CHECK-NEXT: ret i1 [[C15]]483;484 %not.L = xor i1 %L, true485 %cmp1 = icmp eq ptr getelementptr inbounds (i16, ptr @g1, i64 1), @g1486 %cmp2 = icmp eq ptr getelementptr inbounds (i16, ptr @g2, i64 1), @g1487 %add = add i1 %cmp1, %cmp2488 %xor = xor i1 %add, true489 %C15 = select i1 %not.L, i1 %xor, i1 false490 ret i1 %C15491}492 493define i1 @and_or1(i1 %a, i1 %b, i1 %c) {494; CHECK-LABEL: @and_or1(495; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 true, i1 [[B:%.*]]496; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 [[TMP1]], i1 false497; CHECK-NEXT: ret i1 [[R]]498;499 %nota = xor i1 %a, true500 %cond = or i1 %nota, %c501 %r = select i1 %cond, i1 %a, i1 %b502 ret i1 %r503}504 505define i1 @and_or2(i1 %a, i1 %b, i1 %c) {506; CHECK-LABEL: @and_or2(507; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 true, i1 [[A:%.*]]508; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 [[TMP1]], i1 false509; CHECK-NEXT: ret i1 [[R]]510;511 %notc = xor i1 %c, true512 %cond = and i1 %notc, %b513 %r = select i1 %cond, i1 %a, i1 %b514 ret i1 %r515}516 517define i1 @and_or1_commuted(i1 %a, i1 %b, i1 %c) {518; CHECK-LABEL: @and_or1_commuted(519; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 true, i1 [[B:%.*]]520; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 [[TMP1]], i1 false521; CHECK-NEXT: ret i1 [[R]]522;523 %nota = xor i1 %a, true524 %cond = or i1 %c, %nota525 %r = select i1 %cond, i1 %a, i1 %b526 ret i1 %r527}528 529define i1 @and_or2_commuted(i1 %a, i1 %b, i1 %c) {530; CHECK-LABEL: @and_or2_commuted(531; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 true, i1 [[A:%.*]]532; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 [[TMP1]], i1 false533; CHECK-NEXT: ret i1 [[R]]534;535 %notc = xor i1 %c, true536 %cond = and i1 %b, %notc537 %r = select i1 %cond, i1 %a, i1 %b538 ret i1 %r539}540 541define i1 @and_or1_multiuse(i1 %a, i1 %b, i1 %c) {542; CHECK-LABEL: @and_or1_multiuse(543; CHECK-NEXT: [[NOTA:%.*]] = xor i1 [[A:%.*]], true544; CHECK-NEXT: [[COND:%.*]] = or i1 [[C:%.*]], [[NOTA]]545; CHECK-NEXT: call void @use(i1 [[COND]])546; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A]], i1 [[B:%.*]]547; CHECK-NEXT: ret i1 [[R]]548;549 %nota = xor i1 %a, true550 %cond = or i1 %nota, %c551 call void @use(i1 %cond)552 %r = select i1 %cond, i1 %a, i1 %b553 ret i1 %r554}555 556define i1 @and_or2_multiuse(i1 %a, i1 %b, i1 %c) {557; CHECK-LABEL: @and_or2_multiuse(558; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true559; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[NOTC]]560; CHECK-NEXT: call void @use(i1 [[COND]])561; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]562; CHECK-NEXT: ret i1 [[R]]563;564 %notc = xor i1 %c, true565 %cond = and i1 %notc, %b566 call void @use(i1 %cond)567 %r = select i1 %cond, i1 %a, i1 %b568 ret i1 %r569}570 571define <2 x i1> @and_or1_vec(<2 x i1> %a, <2 x i1> %b) {572; CHECK-LABEL: @and_or1_vec(573; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()574; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> splat (i1 true), <2 x i1> [[B:%.*]]575; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> [[TMP1]], <2 x i1> zeroinitializer576; CHECK-NEXT: ret <2 x i1> [[R]]577;578 %c = call <2 x i1> @gen_v2i1()579 %nota = xor <2 x i1> %a, <i1 true, i1 true>580 %cond = or <2 x i1> %nota, %c581 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b582 ret <2 x i1> %r583}584 585define <2 x i1> @and_or2_vec(<2 x i1> %a, <2 x i1> %b) {586; CHECK-LABEL: @and_or2_vec(587; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()588; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> splat (i1 true), <2 x i1> [[A:%.*]]589; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> [[TMP1]], <2 x i1> zeroinitializer590; CHECK-NEXT: ret <2 x i1> [[R]]591;592 %c = call <2 x i1> @gen_v2i1()593 %notc = xor <2 x i1> %c, <i1 true, i1 true>594 %cond = and <2 x i1> %notc, %b595 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b596 ret <2 x i1> %r597}598 599define <2 x i1> @and_or1_vec_commuted(<2 x i1> %a, <2 x i1> %b) {600; CHECK-LABEL: @and_or1_vec_commuted(601; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()602; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> splat (i1 true), <2 x i1> [[B:%.*]]603; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> [[TMP1]], <2 x i1> zeroinitializer604; CHECK-NEXT: ret <2 x i1> [[R]]605;606 %c = call <2 x i1> @gen_v2i1()607 %nota = xor <2 x i1> %a, <i1 true, i1 true>608 %cond = or <2 x i1> %c, %nota609 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b610 ret <2 x i1> %r611}612 613define <2 x i1> @and_or2_vec_commuted(<2 x i1> %a, <2 x i1> %b) {614; CHECK-LABEL: @and_or2_vec_commuted(615; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()616; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> splat (i1 true), <2 x i1> [[A:%.*]]617; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> [[TMP1]], <2 x i1> zeroinitializer618; CHECK-NEXT: ret <2 x i1> [[R]]619;620 %c = call <2 x i1> @gen_v2i1()621 %notc = xor <2 x i1> %c, <i1 true, i1 true>622 %cond = and <2 x i1> %b, %notc623 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b624 ret <2 x i1> %r625}626 627define i1 @and_or1_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {628; CHECK-LABEL: @and_or1_wrong_operand(629; CHECK-NEXT: [[NOTA:%.*]] = xor i1 [[A:%.*]], true630; CHECK-NEXT: [[COND:%.*]] = or i1 [[C:%.*]], [[NOTA]]631; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[D:%.*]], i1 [[B:%.*]]632; CHECK-NEXT: ret i1 [[R]]633;634 %nota = xor i1 %a, true635 %cond = or i1 %nota, %c636 %r = select i1 %cond, i1 %d, i1 %b637 ret i1 %r638}639 640define i1 @and_or2_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {641; CHECK-LABEL: @and_or2_wrong_operand(642; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true643; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[NOTC]]644; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[D:%.*]]645; CHECK-NEXT: ret i1 [[R]]646;647 %notc = xor i1 %c, true648 %cond = and i1 %notc, %b649 %r = select i1 %cond, i1 %a, i1 %d650 ret i1 %r651}652 653define i1 @and_or3(i1 %a, i1 %b, i32 %x, i32 %y) {654; CHECK-LABEL: @and_or3(655; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], [[Y:%.*]]656; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 true, i1 [[A:%.*]]657; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 [[TMP2]], i1 false658; CHECK-NEXT: ret i1 [[R]]659;660 %c = icmp eq i32 %x, %y661 %cond = and i1 %b, %c662 %r = select i1 %cond, i1 %a, i1 %b663 ret i1 %r664}665 666define i1 @and_or3_commuted(i1 %a, i1 %b, i32 %x, i32 %y) {667; CHECK-LABEL: @and_or3_commuted(668; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], [[Y:%.*]]669; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 true, i1 [[A:%.*]]670; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 [[TMP2]], i1 false671; CHECK-NEXT: ret i1 [[R]]672;673 %c = icmp eq i32 %x, %y674 %cond = and i1 %c, %b675 %r = select i1 %cond, i1 %a, i1 %b676 ret i1 %r677}678 679define i1 @and_or3_not_free_to_invert(i1 %a, i1 %b, i1 %c) {680; CHECK-LABEL: @and_or3_not_free_to_invert(681; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[C:%.*]]682; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]683; CHECK-NEXT: ret i1 [[R]]684;685 %cond = and i1 %b, %c686 %r = select i1 %cond, i1 %a, i1 %b687 ret i1 %r688}689 690define i1 @and_or3_multiuse(i1 %a, i1 %b, i32 %x, i32 %y) {691; CHECK-LABEL: @and_or3_multiuse(692; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]693; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[C]]694; CHECK-NEXT: call void @use(i1 [[COND]])695; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]696; CHECK-NEXT: ret i1 [[R]]697;698 %c = icmp eq i32 %x, %y699 %cond = and i1 %b, %c700 call void @use(i1 %cond)701 %r = select i1 %cond, i1 %a, i1 %b702 ret i1 %r703}704 705define <2 x i1> @and_or3_vec(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {706; CHECK-LABEL: @and_or3_vec(707; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i32> [[X:%.*]], [[Y:%.*]]708; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i1> splat (i1 true), <2 x i1> [[A:%.*]]709; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> [[TMP2]], <2 x i1> zeroinitializer710; CHECK-NEXT: ret <2 x i1> [[R]]711;712 %c = icmp eq <2 x i32> %x, %y713 %cond = and <2 x i1> %b, %c714 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b715 ret <2 x i1> %r716}717 718define <2 x i1> @and_or3_vec_commuted(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {719; CHECK-LABEL: @and_or3_vec_commuted(720; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i32> [[X:%.*]], [[Y:%.*]]721; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i1> splat (i1 true), <2 x i1> [[A:%.*]]722; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> [[TMP2]], <2 x i1> zeroinitializer723; CHECK-NEXT: ret <2 x i1> [[R]]724;725 %c = icmp eq <2 x i32> %x, %y726 %cond = and <2 x i1> %c, %b727 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b728 ret <2 x i1> %r729}730 731define i1 @and_or3_wrong_operand(i1 %a, i1 %b, i32 %x, i32 %y, i1 %d) {732; CHECK-LABEL: @and_or3_wrong_operand(733; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]734; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[C]]735; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[D:%.*]]736; CHECK-NEXT: ret i1 [[R]]737;738 %c = icmp eq i32 %x, %y739 %cond = and i1 %b, %c740 %r = select i1 %cond, i1 %a, i1 %d741 ret i1 %r742}743 744define i1 @or_and1(i1 %a, i1 %b, i1 %c) {745; CHECK-LABEL: @or_and1(746; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 [[A:%.*]], i1 false747; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 true, i1 [[TMP1]]748; CHECK-NEXT: ret i1 [[R]]749;750 %notb = xor i1 %b, true751 %cond = and i1 %notb, %c752 %r = select i1 %cond, i1 %a, i1 %b753 ret i1 %r754}755 756define i1 @or_and2(i1 %a, i1 %b, i1 %c) {757; CHECK-LABEL: @or_and2(758; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 [[B:%.*]], i1 false759; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[TMP1]]760; CHECK-NEXT: ret i1 [[R]]761;762 %notc = xor i1 %c, true763 %cond = or i1 %notc, %a764 %r = select i1 %cond, i1 %a, i1 %b765 ret i1 %r766}767 768define i1 @or_and1_commuted(i1 %a, i1 %b, i1 %c) {769; CHECK-LABEL: @or_and1_commuted(770; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 [[A:%.*]], i1 false771; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], i1 true, i1 [[TMP1]]772; CHECK-NEXT: ret i1 [[R]]773;774 %notb = xor i1 %b, true775 %cond = and i1 %c, %notb776 %r = select i1 %cond, i1 %a, i1 %b777 ret i1 %r778}779 780define i1 @or_and2_commuted(i1 %a, i1 %b, i1 %c) {781; CHECK-LABEL: @or_and2_commuted(782; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 [[B:%.*]], i1 false783; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[TMP1]]784; CHECK-NEXT: ret i1 [[R]]785;786 %notc = xor i1 %c, true787 %cond = or i1 %a, %notc788 %r = select i1 %cond, i1 %a, i1 %b789 ret i1 %r790}791 792define i1 @or_and1_multiuse(i1 %a, i1 %b, i1 %c) {793; CHECK-LABEL: @or_and1_multiuse(794; CHECK-NEXT: [[NOTB:%.*]] = xor i1 [[B:%.*]], true795; CHECK-NEXT: [[COND:%.*]] = and i1 [[C:%.*]], [[NOTB]]796; CHECK-NEXT: call void @use(i1 [[COND]])797; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]798; CHECK-NEXT: ret i1 [[R]]799;800 %notb = xor i1 %b, true801 %cond = and i1 %notb, %c802 call void @use(i1 %cond)803 %r = select i1 %cond, i1 %a, i1 %b804 ret i1 %r805}806 807define i1 @or_and2_multiuse(i1 %a, i1 %b, i1 %c) {808; CHECK-LABEL: @or_and2_multiuse(809; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true810; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[NOTC]]811; CHECK-NEXT: call void @use(i1 [[COND]])812; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A]], i1 [[B:%.*]]813; CHECK-NEXT: ret i1 [[R]]814;815 %notc = xor i1 %c, true816 %cond = or i1 %notc, %a817 call void @use(i1 %cond)818 %r = select i1 %cond, i1 %a, i1 %b819 ret i1 %r820}821 822define <2 x i1> @or_and1_vec(<2 x i1> %a, <2 x i1> %b) {823; CHECK-LABEL: @or_and1_vec(824; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()825; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> [[A:%.*]], <2 x i1> zeroinitializer826; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP1]]827; CHECK-NEXT: ret <2 x i1> [[R]]828;829 %c = call <2 x i1> @gen_v2i1()830 %notb = xor <2 x i1> %b, <i1 true, i1 true>831 %cond = and <2 x i1> %c, %notb832 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b833 ret <2 x i1> %r834}835 836define <2 x i1> @or_and2_vec(<2 x i1> %a, <2 x i1> %b) {837; CHECK-LABEL: @or_and2_vec(838; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()839; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> [[B:%.*]], <2 x i1> zeroinitializer840; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP1]]841; CHECK-NEXT: ret <2 x i1> [[R]]842;843 %c = call <2 x i1> @gen_v2i1()844 %notc = xor <2 x i1> %c, <i1 true, i1 true>845 %cond = or <2 x i1> %a, %notc846 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b847 ret <2 x i1> %r848}849 850define <2 x i1> @or_and1_vec_commuted(<2 x i1> %a, <2 x i1> %b) {851; CHECK-LABEL: @or_and1_vec_commuted(852; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()853; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> [[A:%.*]], <2 x i1> zeroinitializer854; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[B:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP1]]855; CHECK-NEXT: ret <2 x i1> [[R]]856;857 %c = call <2 x i1> @gen_v2i1()858 %notb = xor <2 x i1> %b, <i1 true, i1 true>859 %cond = and <2 x i1> %notb, %c860 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b861 ret <2 x i1> %r862}863 864define <2 x i1> @or_and2_vec_commuted(<2 x i1> %a, <2 x i1> %b) {865; CHECK-LABEL: @or_and2_vec_commuted(866; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()867; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i1> [[B:%.*]], <2 x i1> zeroinitializer868; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP1]]869; CHECK-NEXT: ret <2 x i1> [[R]]870;871 %c = call <2 x i1> @gen_v2i1()872 %notc = xor <2 x i1> %c, <i1 true, i1 true>873 %cond = or <2 x i1> %notc, %a874 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b875 ret <2 x i1> %r876}877 878define i1 @or_and1_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {879; CHECK-LABEL: @or_and1_wrong_operand(880; CHECK-NEXT: [[NOTB:%.*]] = xor i1 [[B:%.*]], true881; CHECK-NEXT: [[COND:%.*]] = and i1 [[C:%.*]], [[NOTB]]882; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[D:%.*]]883; CHECK-NEXT: ret i1 [[R]]884;885 %notb = xor i1 %b, true886 %cond = and i1 %c, %notb887 %r = select i1 %cond, i1 %a, i1 %d888 ret i1 %r889}890 891define i1 @or_and2_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {892; CHECK-LABEL: @or_and2_wrong_operand(893; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true894; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[NOTC]]895; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[D:%.*]], i1 [[B:%.*]]896; CHECK-NEXT: ret i1 [[R]]897;898 %notc = xor i1 %c, true899 %cond = or i1 %a, %notc900 %r = select i1 %cond, i1 %d, i1 %b901 ret i1 %r902}903 904define i1 @pr64558(i1 noundef %a, i1 noundef %b) {905; CHECK-LABEL: @pr64558(906; CHECK-NEXT: entry:907; CHECK-NEXT: [[COND_V:%.*]] = or i1 [[B:%.*]], [[A:%.*]]908; CHECK-NEXT: ret i1 [[COND_V]]909;910entry:911 %lnot = xor i1 %b, true912 %and11 = and i1 %lnot, %a913 %cond.v = select i1 %and11, i1 %a, i1 %b914 ret i1 %cond.v915}916 917define i1 @or_and3(i1 %a, i1 %b, i32 %x, i32 %y) {918; CHECK-LABEL: @or_and3(919; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], [[Y:%.*]]920; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 [[B:%.*]], i1 false921; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[TMP2]]922; CHECK-NEXT: ret i1 [[R]]923;924 %c = icmp eq i32 %x, %y925 %cond = or i1 %a, %c926 %r = select i1 %cond, i1 %a, i1 %b927 ret i1 %r928}929 930define i1 @or_and3_commuted(i1 %a, i1 %b, i32 %x, i32 %y) {931; CHECK-LABEL: @or_and3_commuted(932; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], [[Y:%.*]]933; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 [[B:%.*]], i1 false934; CHECK-NEXT: [[R:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[TMP2]]935; CHECK-NEXT: ret i1 [[R]]936;937 %c = icmp eq i32 %x, %y938 %cond = or i1 %c, %a939 %r = select i1 %cond, i1 %a, i1 %b940 ret i1 %r941}942 943define i1 @or_and3_not_free_to_invert(i1 %a, i1 %b, i1 %c) {944; CHECK-LABEL: @or_and3_not_free_to_invert(945; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[C:%.*]]946; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A]], i1 [[B:%.*]]947; CHECK-NEXT: ret i1 [[R]]948;949 %cond = or i1 %a, %c950 %r = select i1 %cond, i1 %a, i1 %b951 ret i1 %r952}953 954define i1 @or_and3_multiuse(i1 %a, i1 %b, i32 %x, i32 %y) {955; CHECK-LABEL: @or_and3_multiuse(956; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]957; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[C]]958; CHECK-NEXT: call void @use(i1 [[COND]])959; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A]], i1 [[B:%.*]]960; CHECK-NEXT: ret i1 [[R]]961;962 %c = icmp eq i32 %x, %y963 %cond = or i1 %a, %c964 call void @use(i1 %cond)965 %r = select i1 %cond, i1 %a, i1 %b966 ret i1 %r967}968 969define <2 x i1> @or_and3_vec(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {970; CHECK-LABEL: @or_and3_vec(971; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i32> [[X:%.*]], [[Y:%.*]]972; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i1> [[B:%.*]], <2 x i1> zeroinitializer973; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP2]]974; CHECK-NEXT: ret <2 x i1> [[R]]975;976 %c = icmp eq <2 x i32> %x, %y977 %cond = or <2 x i1> %a, %c978 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b979 ret <2 x i1> %r980}981 982define <2 x i1> @or_and3_vec_commuted(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {983; CHECK-LABEL: @or_and3_vec_commuted(984; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i32> [[X:%.*]], [[Y:%.*]]985; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i1> [[B:%.*]], <2 x i1> zeroinitializer986; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A:%.*]], <2 x i1> splat (i1 true), <2 x i1> [[TMP2]]987; CHECK-NEXT: ret <2 x i1> [[R]]988;989 %c = icmp eq <2 x i32> %x, %y990 %cond = or <2 x i1> %c, %a991 %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b992 ret <2 x i1> %r993}994 995define i1 @or_and3_wrong_operand(i1 %a, i1 %b, i32 %x, i32 %y, i1 %d) {996; CHECK-LABEL: @or_and3_wrong_operand(997; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]998; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[C]]999; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[D:%.*]], i1 [[B:%.*]]1000; CHECK-NEXT: ret i1 [[R]]1001;1002 %c = icmp eq i32 %x, %y1003 %cond = or i1 %a, %c1004 %r = select i1 %cond, i1 %d, i1 %b1005 ret i1 %r1006}1007 1008define i8 @test_or_umax(i8 %x, i8 %y, i1 %cond) {1009; CHECK-LABEL: @test_or_umax(1010; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1011; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[X]], i8 [[TMP1]]1012; CHECK-NEXT: ret i8 [[RET]]1013;1014 %cmp = icmp ugt i8 %x, %y1015 %or = select i1 %cond, i1 true, i1 %cmp1016 %ret = select i1 %or, i8 %x, i8 %y1017 ret i8 %ret1018}1019 1020define i8 @test_or_umin(i8 %x, i8 %y, i1 %cond) {1021; CHECK-LABEL: @test_or_umin(1022; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1023; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[Y]], i8 [[TMP1]]1024; CHECK-NEXT: ret i8 [[RET]]1025;1026 %cmp = icmp ugt i8 %x, %y1027 %or = select i1 %cond, i1 true, i1 %cmp1028 %ret = select i1 %or, i8 %y, i8 %x1029 ret i8 %ret1030}1031 1032define i8 @test_and_umax(i8 %x, i8 %y, i1 %cond) {1033; CHECK-LABEL: @test_and_umax(1034; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1035; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[TMP1]], i8 [[Y]]1036; CHECK-NEXT: ret i8 [[RET]]1037;1038 %cmp = icmp ugt i8 %x, %y1039 %and = select i1 %cond, i1 %cmp, i1 false1040 %ret = select i1 %and, i8 %x, i8 %y1041 ret i8 %ret1042}1043 1044define i8 @test_and_umin(i8 %x, i8 %y, i1 %cond) {1045; CHECK-LABEL: @test_and_umin(1046; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1047; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[TMP1]], i8 [[X]]1048; CHECK-NEXT: ret i8 [[RET]]1049;1050 %cmp = icmp ugt i8 %x, %y1051 %and = select i1 %cond, i1 %cmp, i1 false1052 %ret = select i1 %and, i8 %y, i8 %x1053 ret i8 %ret1054}1055 1056define i8 @test_or_umax_bitwise1(i8 %x, i8 %y, i8 %val) {1057; CHECK-LABEL: @test_or_umax_bitwise1(1058; CHECK-NEXT: [[COND:%.*]] = icmp eq i8 [[VAL:%.*]], 01059; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1060; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[TMP1]]1061; CHECK-NEXT: ret i8 [[RET]]1062;1063 %cond = icmp eq i8 %val, 0 ; thwart complexity-based ordering1064 %cmp = icmp ugt i8 %x, %y1065 %or = or i1 %cond, %cmp1066 %ret = select i1 %or, i8 %x, i8 %y1067 ret i8 %ret1068}1069 1070define i8 @test_or_umax_bitwise2(i8 %x, i8 %y, i8 %val) {1071; CHECK-LABEL: @test_or_umax_bitwise2(1072; CHECK-NEXT: [[COND:%.*]] = icmp eq i8 [[VAL:%.*]], 01073; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1074; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[TMP1]]1075; CHECK-NEXT: ret i8 [[RET]]1076;1077 %cond = icmp eq i8 %val, 0 ; thwart complexity-based ordering1078 %cmp = icmp ugt i8 %x, %y1079 %or = or i1 %cmp, %cond1080 %ret = select i1 %or, i8 %x, i8 %y1081 ret i8 %ret1082}1083 1084define i8 @test_and_umax_bitwise1(i8 %x, i8 %y, i8 %val) {1085; CHECK-LABEL: @test_and_umax_bitwise1(1086; CHECK-NEXT: [[COND:%.*]] = icmp eq i8 [[VAL:%.*]], 01087; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1088; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND]], i8 [[TMP1]], i8 [[Y]]1089; CHECK-NEXT: ret i8 [[RET]]1090;1091 %cond = icmp eq i8 %val, 0 ; thwart complexity-based ordering1092 %cmp = icmp ugt i8 %x, %y1093 %and = and i1 %cond, %cmp1094 %ret = select i1 %and, i8 %x, i8 %y1095 ret i8 %ret1096}1097 1098define i8 @test_and_umax_bitwise2(i8 %x, i8 %y, i8 %val) {1099; CHECK-LABEL: @test_and_umax_bitwise2(1100; CHECK-NEXT: [[COND:%.*]] = icmp eq i8 [[VAL:%.*]], 01101; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1102; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND]], i8 [[TMP1]], i8 [[Y]]1103; CHECK-NEXT: ret i8 [[RET]]1104;1105 %cond = icmp eq i8 %val, 0 ; thwart complexity-based ordering1106 %cmp = icmp ugt i8 %x, %y1107 %and = and i1 %cmp, %cond1108 %ret = select i1 %and, i8 %x, i8 %y1109 ret i8 %ret1110}1111 1112; Other SPFs1113 1114define i8 @test_or_smax(i8 %x, i8 %y, i1 %cond) {1115; CHECK-LABEL: @test_or_smax(1116; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])1117; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[X]], i8 [[TMP1]]1118; CHECK-NEXT: ret i8 [[RET]]1119;1120 %cmp = icmp sgt i8 %x, %y1121 %or = select i1 %cond, i1 true, i1 %cmp1122 %ret = select i1 %or, i8 %x, i8 %y1123 ret i8 %ret1124}1125 1126define i8 @test_or_abs(i8 %x, i1 %cond) {1127; CHECK-LABEL: @test_or_abs(1128; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)1129; CHECK-NEXT: [[RET:%.*]] = select i1 [[COND:%.*]], i8 [[X]], i8 [[TMP1]]1130; CHECK-NEXT: ret i8 [[RET]]1131;1132 %cmp = icmp sgt i8 %x, -11133 %neg = sub nsw i8 0, %x1134 %or = select i1 %cond, i1 true, i1 %cmp1135 %ret = select i1 %or, i8 %x, i8 %neg1136 ret i8 %ret1137}1138 1139; TODO: fold SPF_FMAXNUM1140define float @test_or_fmaxnum(float %x, float %y, i1 %cond) {1141; CHECK-LABEL: @test_or_fmaxnum(1142; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ogt float [[X:%.*]], [[Y:%.*]]1143; CHECK-NEXT: [[OR:%.*]] = select i1 [[COND:%.*]], i1 true, i1 [[CMP]]1144; CHECK-NEXT: [[RET:%.*]] = select i1 [[OR]], float [[X]], float [[Y]]1145; CHECK-NEXT: ret float [[RET]]1146;1147 %cmp = fcmp nnan ogt float %x, %y1148 %or = select i1 %cond, i1 true, i1 %cmp1149 %ret = select i1 %or, float %x, float %y1150 ret float %ret1151}1152 1153; Negative tests1154 1155define i8 @test_or_umax_invalid_logical(i8 %x, i8 %y, i1 %cond) {1156; CHECK-LABEL: @test_or_umax_invalid_logical(1157; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]1158; CHECK-NEXT: [[OR:%.*]] = select i1 [[CMP]], i1 true, i1 [[COND:%.*]]1159; CHECK-NEXT: [[RET:%.*]] = select i1 [[OR]], i8 [[X]], i8 [[Y]]1160; CHECK-NEXT: ret i8 [[RET]]1161;1162 %cmp = icmp ugt i8 %x, %y1163 %or = select i1 %cmp, i1 true, i1 %cond1164 %ret = select i1 %or, i8 %x, i8 %y1165 ret i8 %ret1166}1167 1168define i8 @test_and_umax_invalid_logical(i8 %x, i8 %y, i1 %cond) {1169; CHECK-LABEL: @test_and_umax_invalid_logical(1170; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]1171; CHECK-NEXT: [[AND:%.*]] = select i1 [[CMP]], i1 [[COND:%.*]], i1 false1172; CHECK-NEXT: [[RET:%.*]] = select i1 [[AND]], i8 [[X]], i8 [[Y]]1173; CHECK-NEXT: ret i8 [[RET]]1174;1175 %cmp = icmp ugt i8 %x, %y1176 %and = select i1 %cmp, i1 %cond, i1 false1177 %ret = select i1 %and, i8 %x, i8 %y1178 ret i8 %ret1179}1180 1181define i8 @test_or_umax_multiuse_cond(i8 %x, i8 %y, i1 %cond) {1182; CHECK-LABEL: @test_or_umax_multiuse_cond(1183; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]1184; CHECK-NEXT: [[OR:%.*]] = select i1 [[COND:%.*]], i1 true, i1 [[CMP]]1185; CHECK-NEXT: call void @use(i1 [[OR]])1186; CHECK-NEXT: [[RET:%.*]] = select i1 [[OR]], i8 [[X]], i8 [[Y]]1187; CHECK-NEXT: ret i8 [[RET]]1188;1189 %cmp = icmp ugt i8 %x, %y1190 %or = select i1 %cond, i1 true, i1 %cmp1191 call void @use(i1 %or)1192 %ret = select i1 %or, i8 %x, i8 %y1193 ret i8 %ret1194}1195 1196; Tests from PR762031197 1198define i8 @test_or_eq_a_b(i1 %other_cond, i8 %a, i8 %b) {1199; CHECK-LABEL: @test_or_eq_a_b(1200; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]1201; CHECK-NEXT: ret i8 [[SELECT]]1202;1203 %cmp = icmp eq i8 %a, %b1204 %cond = or i1 %other_cond, %cmp1205 %select = select i1 %cond, i8 %a, i8 %b1206 ret i8 %select1207}1208 1209define i8 @test_and_ne_a_b(i1 %other_cond, i8 %a, i8 %b) {1210; CHECK-LABEL: @test_and_ne_a_b(1211; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]1212; CHECK-NEXT: ret i8 [[SELECT]]1213;1214 %cmp = icmp ne i8 %a, %b1215 %cond = and i1 %other_cond, %cmp1216 %select = select i1 %cond, i8 %a, i8 %b1217 ret i8 %select1218}1219 1220define i8 @test_or_eq_a_b_commuted(i1 %other_cond, i8 %a, i8 %b) {1221; CHECK-LABEL: @test_or_eq_a_b_commuted(1222; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[B:%.*]], i8 [[A:%.*]]1223; CHECK-NEXT: ret i8 [[SELECT]]1224;1225 %cmp = icmp eq i8 %a, %b1226 %cond = or i1 %other_cond, %cmp1227 %select = select i1 %cond, i8 %b, i8 %a1228 ret i8 %select1229}1230 1231define i8 @test_and_ne_a_b_commuted(i1 %other_cond, i8 %a, i8 %b) {1232; CHECK-LABEL: @test_and_ne_a_b_commuted(1233; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[B:%.*]], i8 [[A:%.*]]1234; CHECK-NEXT: ret i8 [[SELECT]]1235;1236 %cmp = icmp ne i8 %a, %b1237 %cond = and i1 %other_cond, %cmp1238 %select = select i1 %cond, i8 %b, i8 %a1239 ret i8 %select1240}1241 1242define i8 @test_or_eq_different_operands(i8 %a, i8 %b, i8 %c) {1243; CHECK-LABEL: @test_or_eq_different_operands(1244; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A:%.*]], [[C:%.*]]1245; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], i8 [[A]], i8 [[B:%.*]]1246; CHECK-NEXT: ret i8 [[SELECT]]1247;1248 %cmp = icmp eq i8 %a, %c1249 %cmp1 = icmp eq i8 %b, %a1250 %cond = or i1 %cmp, %cmp11251 %select = select i1 %cond, i8 %a, i8 %b1252 ret i8 %select1253}1254 1255define i8 @test_or_eq_a_b_multi_use(i1 %other_cond, i8 %a, i8 %b) {1256; CHECK-LABEL: @test_or_eq_a_b_multi_use(1257; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]1258; CHECK-NEXT: [[COND:%.*]] = or i1 [[OTHER_COND:%.*]], [[CMP]]1259; CHECK-NEXT: call void @use(i1 [[CMP]])1260; CHECK-NEXT: call void @use(i1 [[COND]])1261; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND]], i8 [[A]], i8 [[B]]1262; CHECK-NEXT: ret i8 [[SELECT]]1263;1264 %cmp = icmp eq i8 %a, %b1265 %cond = or i1 %other_cond, %cmp1266 call void @use(i1 %cmp)1267 call void @use(i1 %cond)1268 %select = select i1 %cond, i8 %a, i8 %b1269 ret i8 %select1270}1271 1272define <2 x i8> @test_or_eq_a_b_vec(<2 x i1> %other_cond, <2 x i8> %a, <2 x i8> %b) {1273; CHECK-LABEL: @test_or_eq_a_b_vec(1274; CHECK-NEXT: [[SELECT:%.*]] = select <2 x i1> [[OTHER_COND:%.*]], <2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]]1275; CHECK-NEXT: ret <2 x i8> [[SELECT]]1276;1277 %cmp = icmp eq <2 x i8> %a, %b1278 %cond = or <2 x i1> %other_cond, %cmp1279 %select = select <2 x i1> %cond, <2 x i8> %a, <2 x i8> %b1280 ret <2 x i8> %select1281}1282 1283define i8 @test_or_ne_a_b(i1 %other_cond, i8 %a, i8 %b) {1284; CHECK-LABEL: @test_or_ne_a_b(1285; CHECK-NEXT: ret i8 [[A:%.*]]1286;1287 %cmp = icmp ne i8 %a, %b1288 %cond = or i1 %other_cond, %cmp1289 %select = select i1 %cond, i8 %a, i8 %b1290 ret i8 %select1291}1292 1293define i8 @test_and_ne_different_operands_fail(i8 %a, i8 %b, i8 %c) {1294; CHECK-LABEL: @test_and_ne_different_operands_fail(1295; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[A:%.*]], [[C:%.*]]1296; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 [[B:%.*]], [[C]]1297; CHECK-NEXT: [[COND:%.*]] = and i1 [[CMP]], [[CMP1]]1298; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[COND]], i8 [[B]], i8 [[A]]1299; CHECK-NEXT: ret i8 [[SELECT]]1300;1301 %cmp = icmp ne i8 %a, %c1302 %cmp1 = icmp ne i8 %b, %c1303 %cond = and i1 %cmp, %cmp11304 %select = select i1 %cond, i8 %b, i8 %a1305 ret i8 %select1306}1307 1308define i8 @test_logical_or_eq_a_b(i1 %other_cond, i8 %a, i8 %b) {1309; CHECK-LABEL: @test_logical_or_eq_a_b(1310; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]1311; CHECK-NEXT: ret i8 [[SELECT]]1312;1313 %cmp = icmp eq i8 %a, %b1314 %or.cond = select i1 %other_cond, i1 true, i1 %cmp1315 %select = select i1 %or.cond, i8 %a, i8 %b1316 ret i8 %select1317}1318 1319define i8 @test_logical_commuted_or_eq_a_b(i1 %other_cond, i8 %a, i8 %b) {1320; CHECK-LABEL: @test_logical_commuted_or_eq_a_b(1321; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]1322; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 true, i1 [[OTHER_COND:%.*]]1323; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OR_COND]], i8 [[A]], i8 [[B]]1324; CHECK-NEXT: ret i8 [[SELECT]]1325;1326 %cmp = icmp eq i8 %a, %b1327 %or.cond = select i1 %cmp, i1 true, i1 %other_cond1328 %select = select i1 %or.cond, i8 %a, i8 %b1329 ret i8 %select1330}1331 1332define i8 @test_logical_and_ne_a_b(i1 %other_cond, i8 %a, i8 %b) {1333; CHECK-LABEL: @test_logical_and_ne_a_b(1334; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OTHER_COND:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]1335; CHECK-NEXT: ret i8 [[SELECT]]1336;1337 %cmp = icmp ne i8 %a, %b1338 %or.cond = select i1 %other_cond, i1 %cmp, i1 false1339 %select = select i1 %or.cond, i8 %a, i8 %b1340 ret i8 %select1341}1342 1343define i8 @test_logical_commuted_and_ne_a_b(i1 %other_cond, i8 %a, i8 %b) {1344; CHECK-LABEL: @test_logical_commuted_and_ne_a_b(1345; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[A:%.*]], [[B:%.*]]1346; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[OTHER_COND:%.*]], i1 false1347; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OR_COND]], i8 [[A]], i8 [[B]]1348; CHECK-NEXT: ret i8 [[SELECT]]1349;1350 %cmp = icmp ne i8 %a, %b1351 %or.cond = select i1 %cmp, i1 %other_cond, i1 false1352 %select = select i1 %or.cond, i8 %a, i8 %b1353 ret i8 %select1354}1355 1356!0 = !{!"function_entry_count", i64 1000}1357!1 = !{!"branch_weights", i32 2, i32 3}1358;.1359; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }1360;.1361; CHECK: [[META0:![0-9]+]] = !{!"function_entry_count", i64 1000}1362; CHECK: [[PROF1]] = !{!"branch_weights", i32 3, i32 2}1363;.1364