brintos

brintos / llvm-project-archived public Read only

0
0
Text · 70.1 KiB · f8c97d8 Raw
2431 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=instcombine < %s | FileCheck %s3 4define void @test_shl(i1 %x) {5; CHECK-LABEL: @test_shl(6; CHECK-NEXT:    call void @sink(i8 0)7; CHECK-NEXT:    ret void8;9  %y = zext i1 %x to i810  %z = shl i8 64, %y11  %a = and i8 %z, 112  call void @sink(i8 %a)13  ret void14}15 16define void @test_lshr(i1 %x) {17; CHECK-LABEL: @test_lshr(18; CHECK-NEXT:    call void @sink(i8 0)19; CHECK-NEXT:    ret void20;21  %y = zext i1 %x to i822  %z = lshr i8 64, %y23  %a = and i8 %z, 124  call void @sink(i8 %a)25  ret void26}27 28define void @test_ashr(i1 %x) {29; CHECK-LABEL: @test_ashr(30; CHECK-NEXT:    call void @sink(i8 0)31; CHECK-NEXT:    ret void32;33  %y = zext i1 %x to i834  %z = ashr i8 -16, %y35  %a = and i8 %z, 336  call void @sink(i8 %a)37  ret void38}39 40define void @test_udiv(i8 %x) {41; CHECK-LABEL: @test_udiv(42; CHECK-NEXT:    call void @sink(i8 0)43; CHECK-NEXT:    ret void44;45  %y = udiv i8 10, %x46  %z = and i8 %y, 6447  call void @sink(i8 %z)48  ret void49}50 51define i8 @test_cond(i8 %x) {52; CHECK-LABEL: @test_cond(53; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 354; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[AND]], 055; CHECK-NEXT:    br i1 [[CMP]], label [[IF:%.*]], label [[EXIT:%.*]]56; CHECK:       if:57; CHECK-NEXT:    ret i8 -458; CHECK:       exit:59; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -460; CHECK-NEXT:    ret i8 [[OR2]]61;62  %and = and i8 %x, 363  %cmp = icmp eq i8 %and, 064  br i1 %cmp, label %if, label %exit65 66if:67  %or1 = or i8 %x, -468  ret i8 %or169 70exit:71  %or2 = or i8 %x, -472  ret i8 %or273}74 75define i8 @test_cond_inv(i8 %x) {76; CHECK-LABEL: @test_cond_inv(77; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 378; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[AND]], 079; CHECK-NEXT:    call void @use(i1 [[CMP]])80; CHECK-NEXT:    br i1 [[CMP]], label [[EXIT:%.*]], label [[IF:%.*]]81; CHECK:       if:82; CHECK-NEXT:    ret i8 -483; CHECK:       exit:84; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -485; CHECK-NEXT:    ret i8 [[OR2]]86;87  %and = and i8 %x, 388  %cmp = icmp ne i8 %and, 089  call void @use(i1 %cmp)90  br i1 %cmp, label %exit, label %if91 92if:93  %or1 = or i8 %x, -494  ret i8 %or195 96exit:97  %or2 = or i8 %x, -498  ret i8 %or299}100 101define i8 @test_cond_and(i8 %x, i1 %c) {102; CHECK-LABEL: @test_cond_and(103; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3104; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[AND]], 0105; CHECK-NEXT:    [[COND:%.*]] = and i1 [[CMP]], [[C:%.*]]106; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]107; CHECK:       if:108; CHECK-NEXT:    ret i8 -4109; CHECK:       exit:110; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4111; CHECK-NEXT:    ret i8 [[OR2]]112;113  %and = and i8 %x, 3114  %cmp = icmp eq i8 %and, 0115  %cond = and i1 %cmp, %c116  br i1 %cond, label %if, label %exit117 118if:119  %or1 = or i8 %x, -4120  ret i8 %or1121 122exit:123  %or2 = or i8 %x, -4124  ret i8 %or2125}126 127define i8 @test_cond_and_bothways(i8 %x) {128; CHECK-LABEL: @test_cond_and_bothways(129; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 91130; CHECK-NEXT:    [[CMP0:%.*]] = icmp ne i8 [[AND]], 24131; CHECK-NEXT:    [[CMP1:%.*]] = icmp ne i8 [[X]], 0132; CHECK-NEXT:    [[COND:%.*]] = and i1 [[CMP0]], [[CMP1]]133; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]134; CHECK:       if:135; CHECK-NEXT:    [[OR1:%.*]] = or i8 [[X]], -4136; CHECK-NEXT:    ret i8 [[OR1]]137; CHECK:       exit:138; CHECK-NEXT:    ret i8 -4139;140  %and = and i8 %x, 91141  %cmp0 = icmp ne i8 %and, 24142  %cmp1 = icmp ne i8 %x, 0143  %cond = and i1 %cmp0, %cmp1144  br i1 %cond, label %if, label %exit145 146if:147  %or1 = or i8 %x, -4148  ret i8 %or1149 150exit:151  %or2 = or i8 %x, -4152  ret i8 %or2153}154 155define i8 @test_cond_or_bothways(i8 %x) {156; CHECK-LABEL: @test_cond_or_bothways(157; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 91158; CHECK-NEXT:    [[CMP0:%.*]] = icmp eq i8 [[AND]], 24159; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[X]], 0160; CHECK-NEXT:    [[COND:%.*]] = or i1 [[CMP0]], [[CMP1]]161; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]162; CHECK:       if:163; CHECK-NEXT:    ret i8 -4164; CHECK:       exit:165; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4166; CHECK-NEXT:    ret i8 [[OR2]]167;168  %and = and i8 %x, 91169  %cmp0 = icmp eq i8 %and, 24170  %cmp1 = icmp eq i8 %x, 0171  %cond = or i1 %cmp0, %cmp1172  br i1 %cond, label %if, label %exit173 174if:175  %or1 = or i8 %x, -4176  ret i8 %or1177 178exit:179  %or2 = or i8 %x, -4180  ret i8 %or2181}182 183define i8 @test_cond_and_commuted(i8 %x, i1 %c1, i1 %c2) {184; CHECK-LABEL: @test_cond_and_commuted(185; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3186; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[AND]], 0187; CHECK-NEXT:    [[C3:%.*]] = and i1 [[C1:%.*]], [[C2:%.*]]188; CHECK-NEXT:    [[COND:%.*]] = and i1 [[C3]], [[CMP]]189; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]190; CHECK:       if:191; CHECK-NEXT:    ret i8 -4192; CHECK:       exit:193; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4194; CHECK-NEXT:    ret i8 [[OR2]]195;196  %and = and i8 %x, 3197  %cmp = icmp eq i8 %and, 0198  %c3 = and i1 %c1, %c2199  %cond = and i1 %c3, %cmp200  br i1 %cond, label %if, label %exit201 202if:203  %or1 = or i8 %x, -4204  ret i8 %or1205 206exit:207  %or2 = or i8 %x, -4208  ret i8 %or2209}210 211define i8 @test_cond_logical_and(i8 %x, i1 %c) {212; CHECK-LABEL: @test_cond_logical_and(213; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3214; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[AND]], 0215; CHECK-NEXT:    [[COND:%.*]] = select i1 [[CMP]], i1 [[C:%.*]], i1 false216; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]217; CHECK:       if:218; CHECK-NEXT:    ret i8 -4219; CHECK:       exit:220; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4221; CHECK-NEXT:    ret i8 [[OR2]]222;223  %and = and i8 %x, 3224  %cmp = icmp eq i8 %and, 0225  %cond = select i1 %cmp, i1 %c, i1 false226  br i1 %cond, label %if, label %exit227 228if:229  %or1 = or i8 %x, -4230  ret i8 %or1231 232exit:233  %or2 = or i8 %x, -4234  ret i8 %or2235}236 237define i8 @test_cond_or_invalid(i8 %x, i1 %c) {238; CHECK-LABEL: @test_cond_or_invalid(239; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3240; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[AND]], 0241; CHECK-NEXT:    [[COND:%.*]] = or i1 [[CMP]], [[C:%.*]]242; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]243; CHECK:       if:244; CHECK-NEXT:    [[OR1:%.*]] = or i8 [[X]], -4245; CHECK-NEXT:    ret i8 [[OR1]]246; CHECK:       exit:247; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4248; CHECK-NEXT:    ret i8 [[OR2]]249;250  %and = and i8 %x, 3251  %cmp = icmp eq i8 %and, 0252  %cond = or i1 %cmp, %c253  br i1 %cond, label %if, label %exit254 255if:256  %or1 = or i8 %x, -4257  ret i8 %or1258 259exit:260  %or2 = or i8 %x, -4261  ret i8 %or2262}263 264define i8 @test_cond_inv_or(i8 %x, i1 %c) {265; CHECK-LABEL: @test_cond_inv_or(266; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3267; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[AND]], 0268; CHECK-NEXT:    [[COND:%.*]] = or i1 [[CMP]], [[C:%.*]]269; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]270; CHECK:       if:271; CHECK-NEXT:    [[OR1:%.*]] = or i8 [[X]], -4272; CHECK-NEXT:    ret i8 [[OR1]]273; CHECK:       exit:274; CHECK-NEXT:    ret i8 -4275;276  %and = and i8 %x, 3277  %cmp = icmp ne i8 %and, 0278  %cond = or i1 %cmp, %c279  br i1 %cond, label %if, label %exit280 281if:282  %or1 = or i8 %x, -4283  ret i8 %or1284 285exit:286  %or2 = or i8 %x, -4287  ret i8 %or2288}289 290define i8 @test_cond_inv_logical_or(i8 %x, i1 %c) {291; CHECK-LABEL: @test_cond_inv_logical_or(292; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3293; CHECK-NEXT:    [[CMP_NOT:%.*]] = icmp eq i8 [[AND]], 0294; CHECK-NEXT:    [[COND:%.*]] = select i1 [[CMP_NOT]], i1 [[C:%.*]], i1 false295; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]296; CHECK:       if:297; CHECK-NEXT:    ret i8 -4298; CHECK:       exit:299; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4300; CHECK-NEXT:    ret i8 [[OR2]]301;302  %and = and i8 %x, 3303  %cmp = icmp ne i8 %and, 0304  %cond = select i1 %cmp, i1 false, i1 %c305  br i1 %cond, label %if, label %exit306 307if:308  %or1 = or i8 %x, -4309  ret i8 %or1310 311exit:312  %or2 = or i8 %x, -4313  ret i8 %or2314}315 316define i8 @test_cond_inv_and_invalid(i8 %x, i1 %c) {317; CHECK-LABEL: @test_cond_inv_and_invalid(318; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 3319; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[AND]], 0320; CHECK-NEXT:    [[COND:%.*]] = and i1 [[CMP]], [[C:%.*]]321; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]322; CHECK:       if:323; CHECK-NEXT:    [[OR1:%.*]] = or i8 [[X]], -4324; CHECK-NEXT:    ret i8 [[OR1]]325; CHECK:       exit:326; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -4327; CHECK-NEXT:    ret i8 [[OR2]]328;329  %and = and i8 %x, 3330  %cmp = icmp ne i8 %and, 0331  %cond = and i1 %cmp, %c332  br i1 %cond, label %if, label %exit333 334if:335  %or1 = or i8 %x, -4336  ret i8 %or1337 338exit:339  %or2 = or i8 %x, -4340  ret i8 %or2341}342 343define i32 @test_icmp_trunc1(i32 %x) {344; CHECK-LABEL: @test_icmp_trunc1(345; CHECK-NEXT:  entry:346; CHECK-NEXT:    [[Y:%.*]] = trunc i32 [[X:%.*]] to i16347; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[Y]], 7348; CHECK-NEXT:    br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]349; CHECK:       then:350; CHECK-NEXT:    ret i32 7351; CHECK:       else:352; CHECK-NEXT:    ret i32 0353;354entry:355  %y = trunc i32 %x to i16356  %cmp = icmp eq i16 %y, 7357  br i1 %cmp, label %then, label %else358then:359  %z = and i32 %x, 15360  ret i32 %z361else:362  ret i32 0363}364 365define i32 @test_icmp_trunc_assume(i32 %x) {366; CHECK-LABEL: @test_icmp_trunc_assume(367; CHECK-NEXT:  entry:368; CHECK-NEXT:    [[Y:%.*]] = trunc i32 [[X:%.*]] to i16369; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[Y]], 7370; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])371; CHECK-NEXT:    ret i32 7372;373entry:374  %y = trunc i32 %x to i16375  %cmp = icmp eq i16 %y, 7376  call void @llvm.assume(i1 %cmp)377  %z = and i32 %x, 15378  ret i32 %z379}380 381define i64 @test_icmp_trunc2(i64 %x) {382; CHECK-LABEL: @test_icmp_trunc2(383; CHECK-NEXT:    [[CONV:%.*]] = trunc i64 [[X:%.*]] to i32384; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[CONV]], 12385; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]386; CHECK:       if.then:387; CHECK-NEXT:    [[SEXT:%.*]] = and i64 [[X]], 2147483647388; CHECK-NEXT:    ret i64 [[SEXT]]389; CHECK:       if.else:390; CHECK-NEXT:    ret i64 0391;392  %conv = trunc i64 %x to i32393  %cmp = icmp sgt i32 %conv, 12394  br i1 %cmp, label %if.then, label %if.else395 396if.then:397  %sext = shl i64 %x, 32398  %ret = ashr exact i64 %sext, 32399  ret i64 %ret400if.else:401  ret i64 0402}403 404define i64 @test_icmp_trunc3(i64 %n) {405; CHECK-LABEL: @test_icmp_trunc3(406; CHECK-NEXT:  entry:407; CHECK-NEXT:    [[CONV:%.*]] = trunc i64 [[N:%.*]] to i32408; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[CONV]], 96409; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]410; CHECK:       if.then:411; CHECK-NEXT:    [[RET:%.*]] = and i64 [[N]], 127412; CHECK-NEXT:    ret i64 [[RET]]413; CHECK:       if.else:414; CHECK-NEXT:    ret i64 0415;416entry:417  %conv = trunc i64 %n to i32418  %cmp = icmp ult i32 %conv, 96419  br i1 %cmp, label %if.then, label %if.else420 421if.then:422  %ret = and i64 %n, 4294967295423  ret i64 %ret424 425if.else:426  ret i64 0427}428 429define i8 @test_icmp_trunc4(i64 %n) {430; CHECK-LABEL: @test_icmp_trunc4(431; CHECK-NEXT:    [[CONV:%.*]] = trunc i64 [[N:%.*]] to i32432; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[CONV]], 10433; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]434; CHECK:       if.then:435; CHECK-NEXT:    [[CONV2:%.*]] = trunc i64 [[N]] to i8436; CHECK-NEXT:    [[ADD:%.*]] = or disjoint i8 [[CONV2]], 48437; CHECK-NEXT:    ret i8 [[ADD]]438; CHECK:       if.else:439; CHECK-NEXT:    ret i8 0440;441  %conv = trunc i64 %n to i32442  %cmp = icmp ult i32 %conv, 10443  br i1 %cmp, label %if.then, label %if.else444 445if.then:446  %conv2 = trunc i64 %n to i8447  %add = add i8 %conv2, 48448  ret i8 %add449 450if.else:451  ret i8 0452}453 454define i64 @test_icmp_trunc5(i64 %n) {455; CHECK-LABEL: @test_icmp_trunc5(456; CHECK-NEXT:  entry:457; CHECK-NEXT:    [[SHR:%.*]] = ashr i64 [[N:%.*]], 47458; CHECK-NEXT:    [[CONV1:%.*]] = trunc nsw i64 [[SHR]] to i32459; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i32 [[CONV1]], -13460; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]461; CHECK:       if.then:462; CHECK-NEXT:    [[TMP0:%.*]] = and i64 [[SHR]], 15463; CHECK-NEXT:    [[NOT:%.*]] = xor i64 [[TMP0]], 15464; CHECK-NEXT:    ret i64 [[NOT]]465; CHECK:       if.else:466; CHECK-NEXT:    ret i64 13467;468entry:469  %shr = ashr i64 %n, 47470  %conv1 = trunc i64 %shr to i32471  %cmp = icmp ugt i32 %conv1, -13472  br i1 %cmp, label %if.then, label %if.else473 474if.then:475  %and = and i64 %shr, 4294967295476  %not = xor i64 %and, 4294967295477  ret i64 %not478 479if.else:480  ret i64 13481}482 483define i64 @test_icmp_trunc_nuw(i64 %a) {484; CHECK-LABEL: @test_icmp_trunc_nuw(485; CHECK-NEXT:  entry:486; CHECK-NEXT:    [[CAST:%.*]] = trunc nuw i64 [[A:%.*]] to i32487; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[CAST]], 0488; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]489; CHECK:       if.then:490; CHECK-NEXT:    ret i64 [[A]]491; CHECK:       if.else:492; CHECK-NEXT:    ret i64 0493;494entry:495  %cast = trunc nuw i64 %a to i32496  %cmp = icmp sgt i32 %cast, 0497  br i1 %cmp, label %if.then, label %if.else498 499if.then:500  %b = and i64 %a, 2147483647501  ret i64 %b502 503if.else:504  ret i64 0505}506 507define i64 @test_icmp_trunc_no_nuw(i64 %a) {508; CHECK-LABEL: @test_icmp_trunc_no_nuw(509; CHECK-NEXT:  entry:510; CHECK-NEXT:    [[CAST:%.*]] = trunc i64 [[A:%.*]] to i32511; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[CAST]], 0512; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]513; CHECK:       if.then:514; CHECK-NEXT:    [[B:%.*]] = and i64 [[A]], 2147483647515; CHECK-NEXT:    ret i64 [[B]]516; CHECK:       if.else:517; CHECK-NEXT:    ret i64 0518;519entry:520  %cast = trunc i64 %a to i32521  %cmp = icmp sgt i32 %cast, 0522  br i1 %cmp, label %if.then, label %if.else523 524if.then:525  %b = and i64 %a, 2147483647526  ret i64 %b527 528if.else:529  ret i64 0530}531 532define i1 @test_icmp_or_distjoint(i8 %n, i1 %other) {533; CHECK-LABEL: @test_icmp_or_distjoint(534; CHECK-NEXT:  entry:535; CHECK-NEXT:    [[N_OR:%.*]] = or disjoint i8 [[N:%.*]], 16536; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_OR]], -111537; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]538; CHECK:       if.then:539; CHECK-NEXT:    ret i1 true540; CHECK:       if.else:541; CHECK-NEXT:    ret i1 [[OTHER:%.*]]542;543entry:544  %n_or = or disjoint i8 %n, 16545  %cmp = icmp ugt i8 %n_or, 145546  br i1 %cmp, label %if.then, label %if.else547 548if.then:549  %r = icmp slt i8 %n, 0550  ret i1 %r551 552if.else:553  ret i1 %other554}555 556define i1 @test_icmp_or_fail_missing_disjoint(i8 %n, i1 %other) {557; CHECK-LABEL: @test_icmp_or_fail_missing_disjoint(558; CHECK-NEXT:  entry:559; CHECK-NEXT:    [[N_OR:%.*]] = or i8 [[N:%.*]], 16560; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_OR]], -111561; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]562; CHECK:       if.then:563; CHECK-NEXT:    [[R:%.*]] = icmp slt i8 [[N]], 0564; CHECK-NEXT:    ret i1 [[R]]565; CHECK:       if.else:566; CHECK-NEXT:    ret i1 [[OTHER:%.*]]567;568entry:569  %n_or = or i8 %n, 16570  %cmp = icmp ugt i8 %n_or, 145571  br i1 %cmp, label %if.then, label %if.else572 573if.then:574  %r = icmp slt i8 %n, 0575  ret i1 %r576 577if.else:578  ret i1 %other579}580 581define i8 @and_eq_bits_must_be_set(i8 %x, i8 %y) {582; CHECK-LABEL: @and_eq_bits_must_be_set(583; CHECK-NEXT:    [[XY:%.*]] = and i8 [[X:%.*]], [[Y:%.*]]584; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 123585; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])586; CHECK-NEXT:    ret i8 1587;588  %xy = and i8 %x, %y589  %cmp = icmp eq i8 %xy, 123590  call void @llvm.assume(i1 %cmp)591  %r = and i8 %x, 1592  ret i8 %r593}594 595define i8 @test_icmp_or(i8 %n, i8 %n2, i8 %other) {596; CHECK-LABEL: @test_icmp_or(597; CHECK-NEXT:  entry:598; CHECK-NEXT:    [[N_OR:%.*]] = or i8 [[N:%.*]], [[N2:%.*]]599; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_OR]], 32600; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]601; CHECK:       if.then:602; CHECK-NEXT:    ret i8 0603; CHECK:       if.else:604; CHECK-NEXT:    ret i8 [[OTHER:%.*]]605;606entry:607  %n_or = or i8 %n, %n2608  %cmp = icmp ult i8 %n_or, 32609  br i1 %cmp, label %if.then, label %if.else610 611if.then:612  %r = and i8 %n, 32613  ret i8 %r614 615if.else:616  ret i8 %other617}618 619define i8 @test_icmp_or2(i8 %n, i8 %n2, i8 %other) {620; CHECK-LABEL: @test_icmp_or2(621; CHECK-NEXT:  entry:622; CHECK-NEXT:    [[N_OR:%.*]] = or i8 [[N:%.*]], [[N2:%.*]]623; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_OR]], 14624; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]625; CHECK:       if.then:626; CHECK-NEXT:    ret i8 [[OTHER:%.*]]627; CHECK:       if.else:628; CHECK-NEXT:    ret i8 0629;630entry:631  %n_or = or i8 %n, %n2632  %cmp = icmp uge i8 %n_or, 15633  br i1 %cmp, label %if.then, label %if.else634 635if.then:636  ret i8 %other637if.else:638  %r = and i8 %n, 32639  ret i8 %r640 641}642 643define i8 @test_icmp_or_fail_bad_range(i8 %n, i8 %n2, i8 %other) {644; CHECK-LABEL: @test_icmp_or_fail_bad_range(645; CHECK-NEXT:  entry:646; CHECK-NEXT:    [[N_OR:%.*]] = or i8 [[N:%.*]], [[N2:%.*]]647; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_OR]], 33648; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]649; CHECK:       if.then:650; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 32651; CHECK-NEXT:    ret i8 [[R]]652; CHECK:       if.else:653; CHECK-NEXT:    ret i8 [[OTHER:%.*]]654;655entry:656  %n_or = or i8 %n, %n2657  %cmp = icmp ule i8 %n_or, 32658  br i1 %cmp, label %if.then, label %if.else659 660if.then:661  %r = and i8 %n, 32662  ret i8 %r663 664if.else:665  ret i8 %other666}667 668define i8 @test_icmp_or_fail_bad_pred(i8 %n, i8 %n2, i8 %other) {669; CHECK-LABEL: @test_icmp_or_fail_bad_pred(670; CHECK-NEXT:  entry:671; CHECK-NEXT:    [[N_OR:%.*]] = or i8 [[N:%.*]], [[N2:%.*]]672; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_OR]], 32673; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]674; CHECK:       if.then:675; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 32676; CHECK-NEXT:    ret i8 [[R]]677; CHECK:       if.else:678; CHECK-NEXT:    ret i8 [[OTHER:%.*]]679;680entry:681  %n_or = or i8 %n, %n2682  %cmp = icmp ugt i8 %n_or, 32683  br i1 %cmp, label %if.then, label %if.else684 685if.then:686  %r = and i8 %n, 32687  ret i8 %r688 689if.else:690  ret i8 %other691}692 693define i8 @test_icmp_and(i8 %n, i8 %n2, i8 %other) {694; CHECK-LABEL: @test_icmp_and(695; CHECK-NEXT:  entry:696; CHECK-NEXT:    [[N_AND:%.*]] = and i8 [[N:%.*]], [[N2:%.*]]697; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_AND]], -33698; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]699; CHECK:       if.then:700; CHECK-NEXT:    ret i8 32701; CHECK:       if.else:702; CHECK-NEXT:    ret i8 [[OTHER:%.*]]703;704entry:705  %n_and = and i8 %n, %n2706  %cmp = icmp ugt i8 %n_and, 223707  br i1 %cmp, label %if.then, label %if.else708 709if.then:710  %r = and i8 %n, 32711  ret i8 %r712 713if.else:714  ret i8 %other715}716 717define i8 @test_icmp_and2(i8 %n, i8 %n2, i8 %other) {718; CHECK-LABEL: @test_icmp_and2(719; CHECK-NEXT:  entry:720; CHECK-NEXT:    [[N_AND:%.*]] = and i8 [[N:%.*]], [[N2:%.*]]721; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_AND]], -31722; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]723; CHECK:       if.then:724; CHECK-NEXT:    ret i8 [[OTHER:%.*]]725; CHECK:       if.else:726; CHECK-NEXT:    ret i8 32727;728entry:729  %n_and = and i8 %n, %n2730  %cmp = icmp ule i8 %n_and, 224731  br i1 %cmp, label %if.then, label %if.else732 733if.then:734  ret i8 %other735if.else:736  %r = and i8 %n, 32737  ret i8 %r738 739}740 741define i8 @test_icmp_and_fail_bad_range(i8 %n, i8 %n2, i8 %other) {742; CHECK-LABEL: @test_icmp_and_fail_bad_range(743; CHECK-NEXT:  entry:744; CHECK-NEXT:    [[N_AND:%.*]] = and i8 [[N:%.*]], [[N2:%.*]]745; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_AND]], -34746; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]747; CHECK:       if.then:748; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 32749; CHECK-NEXT:    ret i8 [[R]]750; CHECK:       if.else:751; CHECK-NEXT:    ret i8 [[OTHER:%.*]]752;753entry:754  %n_and = and i8 %n, %n2755  %cmp = icmp uge i8 %n_and, 223756  br i1 %cmp, label %if.then, label %if.else757 758if.then:759  %r = and i8 %n, 32760  ret i8 %r761 762if.else:763  ret i8 %other764}765 766define i8 @test_icmp_and_fail_bad_pred(i8 %n, i8 %n2, i8 %other) {767; CHECK-LABEL: @test_icmp_and_fail_bad_pred(768; CHECK-NEXT:  entry:769; CHECK-NEXT:    [[N_AND:%.*]] = and i8 [[N:%.*]], [[N2:%.*]]770; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[N_AND]], 31771; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]772; CHECK:       if.then:773; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 32774; CHECK-NEXT:    ret i8 [[R]]775; CHECK:       if.else:776; CHECK-NEXT:    ret i8 [[OTHER:%.*]]777;778entry:779  %n_and = and i8 %n, %n2780  %cmp = icmp sge i8 %n_and, 32781  br i1 %cmp, label %if.then, label %if.else782 783if.then:784  %r = and i8 %n, 32785  ret i8 %r786 787if.else:788  ret i8 %other789}790 791define i8 @and_eq_bits_must_be_set2(i8 %x, i8 %y) {792; CHECK-LABEL: @and_eq_bits_must_be_set2(793; CHECK-NEXT:    [[XY:%.*]] = and i8 [[X:%.*]], [[Y:%.*]]794; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 123795; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])796; CHECK-NEXT:    ret i8 11797;798  %xy = and i8 %x, %y799  %cmp = icmp eq i8 %xy, 123800  call void @llvm.assume(i1 %cmp)801  %r = and i8 %y, 11802  ret i8 %r803}804 805define i8 @and_eq_bits_must_be_set2_partial_fail(i8 %x, i8 %y) {806; CHECK-LABEL: @and_eq_bits_must_be_set2_partial_fail(807; CHECK-NEXT:    [[XY:%.*]] = and i8 [[X:%.*]], [[Y:%.*]]808; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 123809; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])810; CHECK-NEXT:    [[R:%.*]] = and i8 [[Y]], 111811; CHECK-NEXT:    ret i8 [[R]]812;813  %xy = and i8 %x, %y814  %cmp = icmp eq i8 %xy, 123815  call void @llvm.assume(i1 %cmp)816  %r = and i8 %y, 111817  ret i8 %r818}819 820define i8 @or_eq_bits_must_be_unset(i8 %x, i8 %y) {821; CHECK-LABEL: @or_eq_bits_must_be_unset(822; CHECK-NEXT:    [[XY:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]823; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 124824; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])825; CHECK-NEXT:    ret i8 0826;827  %xy = or i8 %x, %y828  %cmp = icmp eq i8 %xy, 124829  call void @llvm.assume(i1 %cmp)830  %r = and i8 %x, 3831  ret i8 %r832}833 834define i8 @or_eq_bits_must_be_unset2(i8 %x, i8 %y) {835; CHECK-LABEL: @or_eq_bits_must_be_unset2(836; CHECK-NEXT:    [[XY:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]837; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 124838; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])839; CHECK-NEXT:    ret i8 0840;841  %xy = or i8 %x, %y842  %cmp = icmp eq i8 %xy, 124843  call void @llvm.assume(i1 %cmp)844  %r = and i8 %y, 1845  ret i8 %r846}847 848define i8 @or_eq_bits_must_be_unset2_partial_fail(i8 %x, i8 %y) {849; CHECK-LABEL: @or_eq_bits_must_be_unset2_partial_fail(850; CHECK-NEXT:    [[XY:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]851; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[XY]], 124852; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])853; CHECK-NEXT:    [[R:%.*]] = and i8 [[Y]], 4854; CHECK-NEXT:    ret i8 [[R]]855;856  %xy = or i8 %x, %y857  %cmp = icmp eq i8 %xy, 124858  call void @llvm.assume(i1 %cmp)859  %r = and i8 %y, 7860  ret i8 %r861}862 863define i8 @or_ne_bits_must_be_unset2_fail(i8 %x, i8 %y) {864; CHECK-LABEL: @or_ne_bits_must_be_unset2_fail(865; CHECK-NEXT:    [[XY:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]866; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[XY]], 124867; CHECK-NEXT:    call void @llvm.assume(i1 [[CMP]])868; CHECK-NEXT:    [[R:%.*]] = and i8 [[X]], 3869; CHECK-NEXT:    ret i8 [[R]]870;871  %xy = or i8 %x, %y872  %cmp = icmp ne i8 %xy, 124873  call void @llvm.assume(i1 %cmp)874  %r = and i8 %x, 3875  ret i8 %r876}877 878declare void @use.i1(i1)879declare void @use.i8(i8)880 881declare void @use.2xi1(<2 x i1>)882 883define i1 @extract_value_uadd(<2 x i8> %xx, <2 x i8> %yy) {884; CHECK-LABEL: @extract_value_uadd(885; CHECK-NEXT:    [[X0:%.*]] = and <2 x i8> [[XX:%.*]], <i8 63, i8 -1>886; CHECK-NEXT:    [[Y0:%.*]] = and <2 x i8> [[YY:%.*]], <i8 63, i8 -1>887; CHECK-NEXT:    [[X:%.*]] = add nuw <2 x i8> [[X0]], <i8 1, i8 0>888; CHECK-NEXT:    [[Y:%.*]] = add nuw <2 x i8> [[Y0]], <i8 1, i8 0>889; CHECK-NEXT:    [[ADD_UOV:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])890; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 1891; CHECK-NEXT:    call void @use.2xi1(<2 x i1> [[UOV]])892; CHECK-NEXT:    ret i1 false893;894  %x0 = and <2 x i8> %xx, <i8 63, i8 255>895  %y0 = and <2 x i8> %yy, <i8 63, i8 255>896  %x = add nuw <2 x i8> %x0, <i8 1, i8 0>897  %y = add nuw <2 x i8> %y0, <i8 1, i8 0>898 899  %add_uov = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow(<2 x i8> %x, <2 x i8> %y)900  %add = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 0901  %uov = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 1902  call void @use.2xi1(<2 x i1> %uov)903  %add_ele = extractelement <2 x i8> %add, i32 0904  %r = icmp eq i8 %add_ele, 0905  ret i1 %r906}907 908define i1 @extract_value_uadd2(<2 x i8> %xx, <2 x i8> %yy) {909; CHECK-LABEL: @extract_value_uadd2(910; CHECK-NEXT:    [[X0:%.*]] = and <2 x i8> [[XX:%.*]], <i8 -1, i8 63>911; CHECK-NEXT:    [[Y0:%.*]] = and <2 x i8> [[YY:%.*]], <i8 -1, i8 63>912; CHECK-NEXT:    [[X:%.*]] = add nuw <2 x i8> [[X0]], <i8 0, i8 1>913; CHECK-NEXT:    [[Y:%.*]] = add nuw <2 x i8> [[Y0]], <i8 0, i8 1>914; CHECK-NEXT:    [[ADD_UOV:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])915; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 1916; CHECK-NEXT:    call void @use.2xi1(<2 x i1> [[UOV]])917; CHECK-NEXT:    ret i1 false918;919  %x0 = and <2 x i8> %xx, <i8 255, i8 63>920  %y0 = and <2 x i8> %yy, <i8 255, i8 63>921  %x = add nuw <2 x i8> %x0, <i8 0, i8 1>922  %y = add nuw <2 x i8> %y0, <i8 0, i8 1>923 924  %add_uov = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow(<2 x i8> %x, <2 x i8> %y)925  %add = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 0926  %uov = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 1927  call void @use.2xi1(<2 x i1> %uov)928  %add_ele = extractelement <2 x i8> %add, i32 1929  %r = icmp eq i8 %add_ele, 0930  ret i1 %r931}932 933define i1 @extract_value_uadd_fail(<2 x i8> %xx, <2 x i8> %yy) {934; CHECK-LABEL: @extract_value_uadd_fail(935; CHECK-NEXT:    [[X0:%.*]] = and <2 x i8> [[XX:%.*]], <i8 63, i8 -1>936; CHECK-NEXT:    [[Y0:%.*]] = and <2 x i8> [[YY:%.*]], <i8 63, i8 -1>937; CHECK-NEXT:    [[X:%.*]] = add nuw <2 x i8> [[X0]], <i8 1, i8 0>938; CHECK-NEXT:    [[Y:%.*]] = add nuw <2 x i8> [[Y0]], <i8 1, i8 0>939; CHECK-NEXT:    [[ADD_UOV:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])940; CHECK-NEXT:    [[ADD:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 0941; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 1942; CHECK-NEXT:    call void @use.2xi1(<2 x i1> [[UOV]])943; CHECK-NEXT:    [[ADD_ELE:%.*]] = extractelement <2 x i8> [[ADD]], i64 1944; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[ADD_ELE]], 0945; CHECK-NEXT:    ret i1 [[R]]946;947  %x0 = and <2 x i8> %xx, <i8 63, i8 255>948  %y0 = and <2 x i8> %yy, <i8 63, i8 255>949  %x = add nuw <2 x i8> %x0, <i8 1, i8 0>950  %y = add nuw <2 x i8> %y0, <i8 1, i8 0>951 952  %add_uov = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow(<2 x i8> %x, <2 x i8> %y)953  %add = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 0954  %uov = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 1955  call void @use.2xi1(<2 x i1> %uov)956  %add_ele = extractelement <2 x i8> %add, i32 1957  %r = icmp eq i8 %add_ele, 0958  ret i1 %r959}960 961define i1 @extract_value_uadd_fail2(<2 x i8> %xx, <2 x i8> %yy, i32 %idx) {962; CHECK-LABEL: @extract_value_uadd_fail2(963; CHECK-NEXT:    [[X0:%.*]] = and <2 x i8> [[XX:%.*]], <i8 63, i8 -1>964; CHECK-NEXT:    [[Y0:%.*]] = and <2 x i8> [[YY:%.*]], <i8 63, i8 -1>965; CHECK-NEXT:    [[X:%.*]] = add nuw <2 x i8> [[X0]], <i8 1, i8 0>966; CHECK-NEXT:    [[Y:%.*]] = add nuw <2 x i8> [[Y0]], <i8 1, i8 0>967; CHECK-NEXT:    [[ADD_UOV:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])968; CHECK-NEXT:    [[ADD:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 0969; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 1970; CHECK-NEXT:    call void @use.2xi1(<2 x i1> [[UOV]])971; CHECK-NEXT:    [[ADD_ELE:%.*]] = extractelement <2 x i8> [[ADD]], i32 [[IDX:%.*]]972; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[ADD_ELE]], 0973; CHECK-NEXT:    ret i1 [[R]]974;975  %x0 = and <2 x i8> %xx, <i8 63, i8 255>976  %y0 = and <2 x i8> %yy, <i8 63, i8 255>977  %x = add nuw <2 x i8> %x0, <i8 1, i8 0>978  %y = add nuw <2 x i8> %y0, <i8 1, i8 0>979 980  %add_uov = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow(<2 x i8> %x, <2 x i8> %y)981  %add = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 0982  %uov = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 1983  call void @use.2xi1(<2 x i1> %uov)984  %add_ele = extractelement <2 x i8> %add, i32 %idx985  %r = icmp eq i8 %add_ele, 0986  ret i1 %r987}988 989define i1 @extract_value_uadd_fail3(<2 x i8> %xx, <2 x i8> %yy) {990; CHECK-LABEL: @extract_value_uadd_fail3(991; CHECK-NEXT:    [[X0:%.*]] = and <2 x i8> [[XX:%.*]], splat (i8 127)992; CHECK-NEXT:    [[Y0:%.*]] = and <2 x i8> [[YY:%.*]], splat (i8 127)993; CHECK-NEXT:    [[X:%.*]] = add nuw <2 x i8> [[X0]], splat (i8 1)994; CHECK-NEXT:    [[Y:%.*]] = add nuw <2 x i8> [[Y0]], splat (i8 1)995; CHECK-NEXT:    [[ADD_UOV:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])996; CHECK-NEXT:    [[ADD:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 0997; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[ADD_UOV]], 1998; CHECK-NEXT:    call void @use.2xi1(<2 x i1> [[UOV]])999; CHECK-NEXT:    [[ADD_ELE:%.*]] = extractelement <2 x i8> [[ADD]], i64 01000; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[ADD_ELE]], 01001; CHECK-NEXT:    ret i1 [[R]]1002;1003  %x0 = and <2 x i8> %xx, <i8 127, i8 127>1004  %y0 = and <2 x i8> %yy, <i8 127, i8 127>1005  %x = add nuw <2 x i8> %x0, <i8 1, i8 1>1006  %y = add nuw <2 x i8> %y0, <i8 1, i8 1>1007 1008  %add_uov = call { <2 x i8>, <2 x i1> } @llvm.uadd.with.overflow(<2 x i8> %x, <2 x i8> %y)1009  %add = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 01010  %uov = extractvalue { <2 x i8>, <2 x i1> } %add_uov, 11011  call void @use.2xi1(<2 x i1> %uov)1012  %add_ele = extractelement <2 x i8> %add, i32 01013  %r = icmp eq i8 %add_ele, 01014  ret i1 %r1015}1016 1017define i1 @extract_value_sadd(i8 %xx, i8 %yy) {1018; CHECK-LABEL: @extract_value_sadd(1019; CHECK-NEXT:    [[X:%.*]] = add nuw i8 [[XX:%.*]], 11020; CHECK-NEXT:    [[Y:%.*]] = add nuw i8 [[YY:%.*]], 11021; CHECK-NEXT:    [[X_LEMMA:%.*]] = icmp sgt i8 [[X]], -11022; CHECK-NEXT:    [[Y_LEMMA:%.*]] = icmp sgt i8 [[Y]], -11023; CHECK-NEXT:    call void @llvm.assume(i1 [[X_LEMMA]])1024; CHECK-NEXT:    call void @llvm.assume(i1 [[Y_LEMMA]])1025; CHECK-NEXT:    [[ADD_SOV:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[X]], i8 [[Y]])1026; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[ADD_SOV]], 11027; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1028; CHECK-NEXT:    ret i1 false1029;1030  %x = add nuw i8 %xx, 11031  %y = add nuw i8 %yy, 11032  %x_lemma = icmp ult i8 %x, 1281033  %y_lemma = icmp ult i8 %y, 1281034  call void @llvm.assume(i1 %x_lemma)1035  call void @llvm.assume(i1 %y_lemma)1036 1037  %add_sov = call { i8, i1 } @llvm.sadd.with.overflow(i8 %x, i8 %y)1038  %add = extractvalue { i8, i1 } %add_sov, 01039  %sov = extractvalue { i8, i1 } %add_sov, 11040  call void @use.i1(i1 %sov)1041  %r = icmp eq i8 %add, 01042  ret i1 %r1043}1044 1045define i1 @extract_value_sadd_fail(i8 %xx, i8 %yy) {1046; CHECK-LABEL: @extract_value_sadd_fail(1047; CHECK-NEXT:    [[X:%.*]] = add i8 [[XX:%.*]], 11048; CHECK-NEXT:    [[Y:%.*]] = add i8 [[YY:%.*]], 11049; CHECK-NEXT:    [[ADD_SOV:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[X]], i8 [[Y]])1050; CHECK-NEXT:    [[ADD:%.*]] = extractvalue { i8, i1 } [[ADD_SOV]], 01051; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[ADD_SOV]], 11052; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1053; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[ADD]], 01054; CHECK-NEXT:    ret i1 [[R]]1055;1056  %x = add i8 %xx, 11057  %y = add i8 %yy, 11058 1059  %add_sov = call { i8, i1 } @llvm.sadd.with.overflow(i8 %x, i8 %y)1060  %add = extractvalue { i8, i1 } %add_sov, 01061  %sov = extractvalue { i8, i1 } %add_sov, 11062  call void @use.i1(i1 %sov)1063  %r = icmp eq i8 %add, 01064  ret i1 %r1065}1066 1067define i1 @extract_value_usub(i8 %x, i8 %zz) {1068; CHECK-LABEL: @extract_value_usub(1069; CHECK-NEXT:    [[Z:%.*]] = add nuw i8 [[ZZ:%.*]], 11070; CHECK-NEXT:    [[Y:%.*]] = add i8 [[X:%.*]], [[Z]]1071; CHECK-NEXT:    [[SUB_UOV:%.*]] = call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[X]], i8 [[Y]])1072; CHECK-NEXT:    [[SUB:%.*]] = extractvalue { i8, i1 } [[SUB_UOV]], 01073; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { i8, i1 } [[SUB_UOV]], 11074; CHECK-NEXT:    call void @use.i1(i1 [[UOV]])1075; CHECK-NEXT:    call void @use.i8(i8 [[SUB]])1076; CHECK-NEXT:    ret i1 false1077;1078  %z = add nuw i8 %zz, 11079  %y = add i8 %x, %z1080 1081  %sub_uov = call { i8, i1 } @llvm.usub.with.overflow(i8 %x, i8 %y)1082  %sub = extractvalue { i8, i1 } %sub_uov, 01083  %uov = extractvalue { i8, i1 } %sub_uov, 11084  call void @use.i1(i1 %uov)1085  call void @use.i8(i8 %sub)1086  %r = icmp eq i8 %sub, 01087  ret i1 %r1088}1089 1090define i1 @extract_value_usub_fail(i8 %x, i8 %z) {1091; CHECK-LABEL: @extract_value_usub_fail(1092; CHECK-NEXT:    [[Y:%.*]] = add i8 [[X:%.*]], [[Z:%.*]]1093; CHECK-NEXT:    [[SUB_UOV:%.*]] = call { i8, i1 } @llvm.usub.with.overflow.i8(i8 [[X]], i8 [[Y]])1094; CHECK-NEXT:    [[SUB:%.*]] = extractvalue { i8, i1 } [[SUB_UOV]], 01095; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { i8, i1 } [[SUB_UOV]], 11096; CHECK-NEXT:    call void @use.i1(i1 [[UOV]])1097; CHECK-NEXT:    call void @use.i8(i8 [[SUB]])1098; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[SUB]], 01099; CHECK-NEXT:    ret i1 [[R]]1100;1101  %y = add i8 %x, %z1102  %sub_uov = call { i8, i1 } @llvm.usub.with.overflow(i8 %x, i8 %y)1103  %sub = extractvalue { i8, i1 } %sub_uov, 01104  %uov = extractvalue { i8, i1 } %sub_uov, 11105  call void @use.i1(i1 %uov)1106  call void @use.i8(i8 %sub)1107  %r = icmp eq i8 %sub, 01108  ret i1 %r1109}1110 1111define i1 @extract_value_ssub(i8 %x, i8 %zz) {1112; CHECK-LABEL: @extract_value_ssub(1113; CHECK-NEXT:    [[Z:%.*]] = add nuw i8 [[ZZ:%.*]], 11114; CHECK-NEXT:    [[Y:%.*]] = add i8 [[X:%.*]], [[Z]]1115; CHECK-NEXT:    [[SUB_SOV:%.*]] = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 [[Y]], i8 [[X]])1116; CHECK-NEXT:    [[SUB:%.*]] = extractvalue { i8, i1 } [[SUB_SOV]], 01117; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[SUB_SOV]], 11118; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1119; CHECK-NEXT:    call void @use.i8(i8 [[SUB]])1120; CHECK-NEXT:    ret i1 false1121;1122  %z = add nuw i8 %zz, 11123  %y = add i8 %x, %z1124 1125  %sub_sov = call { i8, i1 } @llvm.ssub.with.overflow(i8 %y, i8 %x)1126  %sub = extractvalue { i8, i1 } %sub_sov, 01127  %sov = extractvalue { i8, i1 } %sub_sov, 11128  call void @use.i1(i1 %sov)1129  call void @use.i8(i8 %sub)1130  %r = icmp eq i8 %sub, 01131  ret i1 %r1132}1133 1134define i1 @extract_value_ssub_fail(i8 %x) {1135; CHECK-LABEL: @extract_value_ssub_fail(1136; CHECK-NEXT:    [[SUB_SOV:%.*]] = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 10, i8 [[X:%.*]])1137; CHECK-NEXT:    [[SUB:%.*]] = extractvalue { i8, i1 } [[SUB_SOV]], 01138; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[SUB_SOV]], 11139; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1140; CHECK-NEXT:    call void @use.i8(i8 [[SUB]])1141; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[SUB]], 01142; CHECK-NEXT:    ret i1 [[R]]1143;1144  %sub_sov = call { i8, i1 } @llvm.ssub.with.overflow(i8 10, i8 %x)1145  %sub = extractvalue { i8, i1 } %sub_sov, 01146  %sov = extractvalue { i8, i1 } %sub_sov, 11147  call void @use.i1(i1 %sov)1148  call void @use.i8(i8 %sub)1149  %r = icmp eq i8 %sub, 01150  ret i1 %r1151}1152 1153define i1 @extract_value_umul(i8 %xx, i8 %yy) {1154; CHECK-LABEL: @extract_value_umul(1155; CHECK-NEXT:    [[X:%.*]] = or i8 [[XX:%.*]], 11156; CHECK-NEXT:    [[Y:%.*]] = add nuw i8 [[YY:%.*]], 11157; CHECK-NEXT:    [[MUL_UOV:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X]], i8 [[Y]])1158; CHECK-NEXT:    [[MUL:%.*]] = extractvalue { i8, i1 } [[MUL_UOV]], 01159; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { i8, i1 } [[MUL_UOV]], 11160; CHECK-NEXT:    call void @use.i1(i1 [[UOV]])1161; CHECK-NEXT:    call void @use.i8(i8 [[MUL]])1162; CHECK-NEXT:    ret i1 false1163;1164  %x = or i8 %xx, 11165  %y = add nuw i8 %yy, 11166 1167  %mul_uov = call { i8, i1 } @llvm.umul.with.overflow(i8 %x, i8 %y)1168  %mul = extractvalue { i8, i1 } %mul_uov, 01169  %uov = extractvalue { i8, i1 } %mul_uov, 11170  call void @use.i1(i1 %uov)1171  call void @use.i8(i8 %mul)1172  %r = icmp eq i8 %mul, 01173  ret i1 %r1174}1175 1176define i1 @extract_value_umul_fail(i8 %xx, i8 %yy) {1177; CHECK-LABEL: @extract_value_umul_fail(1178; CHECK-NEXT:    [[X:%.*]] = or i8 [[XX:%.*]], 21179; CHECK-NEXT:    [[Y:%.*]] = add nuw i8 [[YY:%.*]], 11180; CHECK-NEXT:    [[MUL_UOV:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X]], i8 [[Y]])1181; CHECK-NEXT:    [[MUL:%.*]] = extractvalue { i8, i1 } [[MUL_UOV]], 01182; CHECK-NEXT:    [[UOV:%.*]] = extractvalue { i8, i1 } [[MUL_UOV]], 11183; CHECK-NEXT:    call void @use.i1(i1 [[UOV]])1184; CHECK-NEXT:    call void @use.i8(i8 [[MUL]])1185; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[MUL]], 01186; CHECK-NEXT:    ret i1 [[R]]1187;1188  %x = or i8 %xx, 21189  %y = add nuw i8 %yy, 11190 1191  %mul_uov = call { i8, i1 } @llvm.umul.with.overflow(i8 %x, i8 %y)1192  %mul = extractvalue { i8, i1 } %mul_uov, 01193  %uov = extractvalue { i8, i1 } %mul_uov, 11194  call void @use.i1(i1 %uov)1195  call void @use.i8(i8 %mul)1196  %r = icmp eq i8 %mul, 01197  ret i1 %r1198}1199 1200define i1 @extract_value_smul(i8 %xx, i8 %yy) {1201; CHECK-LABEL: @extract_value_smul(1202; CHECK-NEXT:    [[X:%.*]] = or i8 [[XX:%.*]], 11203; CHECK-NEXT:    [[Y:%.*]] = add nuw i8 [[YY:%.*]], 11204; CHECK-NEXT:    [[MUL_SOV:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[Y]], i8 [[X]])1205; CHECK-NEXT:    [[MUL:%.*]] = extractvalue { i8, i1 } [[MUL_SOV]], 01206; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[MUL_SOV]], 11207; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1208; CHECK-NEXT:    call void @use.i8(i8 [[MUL]])1209; CHECK-NEXT:    ret i1 false1210;1211  %x = or i8 %xx, 11212  %y = add nuw i8 %yy, 11213 1214  %mul_sov = call { i8, i1 } @llvm.smul.with.overflow(i8 %y, i8 %x)1215  %mul = extractvalue { i8, i1 } %mul_sov, 01216  %sov = extractvalue { i8, i1 } %mul_sov, 11217  call void @use.i1(i1 %sov)1218  call void @use.i8(i8 %mul)1219  %r = icmp eq i8 %mul, 01220  ret i1 %r1221}1222 1223define i1 @extract_value_smul_fail(i8 %xx, i8 %yy) {1224; CHECK-LABEL: @extract_value_smul_fail(1225; CHECK-NEXT:    [[X:%.*]] = or i8 [[XX:%.*]], 11226; CHECK-NEXT:    [[Y:%.*]] = add i8 [[YY:%.*]], 11227; CHECK-NEXT:    [[MUL_SOV:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 [[Y]], i8 [[X]])1228; CHECK-NEXT:    [[MUL:%.*]] = extractvalue { i8, i1 } [[MUL_SOV]], 01229; CHECK-NEXT:    [[SOV:%.*]] = extractvalue { i8, i1 } [[MUL_SOV]], 11230; CHECK-NEXT:    call void @use.i1(i1 [[SOV]])1231; CHECK-NEXT:    call void @use.i8(i8 [[MUL]])1232; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[MUL]], 01233; CHECK-NEXT:    ret i1 [[R]]1234;1235  %x = or i8 %xx, 11236  %y = add i8 %yy, 11237 1238  %mul_sov = call { i8, i1 } @llvm.smul.with.overflow(i8 %y, i8 %x)1239  %mul = extractvalue { i8, i1 } %mul_sov, 01240  %sov = extractvalue { i8, i1 } %mul_sov, 11241  call void @use.i1(i1 %sov)1242  call void @use.i8(i8 %mul)1243  %r = icmp eq i8 %mul, 01244  ret i1 %r1245}1246 1247define i8 @known_self_mul_bit_0_set(i8 noundef %x) {1248; CHECK-LABEL: @known_self_mul_bit_0_set(1249; CHECK-NEXT:    ret i8 01250;1251  %bit_0_set = or i8 %x, 11252  %self_mul = mul i8 %bit_0_set, %bit_0_set1253  %r = and i8 %self_mul, 41254  ret i8 %r1255}1256 1257define i8 @known_self_mul_bit_0_unset(i8 noundef %x) {1258; CHECK-LABEL: @known_self_mul_bit_0_unset(1259; CHECK-NEXT:    ret i8 01260;1261  %bit_0_unset = and i8 %x, -21262  %self_mul = mul i8 %bit_0_unset, %bit_0_unset1263  %r = and i8 %self_mul, 81264  ret i8 %r1265}1266 1267define i8 @known_self_mul_bit_1_set_bit_0_unset(i8 noundef %x) {1268; CHECK-LABEL: @known_self_mul_bit_1_set_bit_0_unset(1269; CHECK-NEXT:    ret i8 01270;1271  %lower_2_unset = and i8 %x, -41272  %bit_1_set_bit_0_unset = or disjoint i8 %lower_2_unset, 21273  %self_mul = mul i8 %bit_1_set_bit_0_unset, %bit_1_set_bit_0_unset1274  %r = and i8 %self_mul, 241275  ret i8 %r1276}1277 1278define i4 @known_self_mul_bit_1_set_bit_0_unset_i4(i4 noundef %x) {1279; CHECK-LABEL: @known_self_mul_bit_1_set_bit_0_unset_i4(1280; CHECK-NEXT:    ret i4 01281;1282  %lower_2_unset = and i4 %x, -41283  %bit_1_set_bit_0_unset = or disjoint i4 %lower_2_unset, 21284  %self_mul = mul i4 %bit_1_set_bit_0_unset, %bit_1_set_bit_0_unset1285  %r = and i4 %self_mul, 241286  ret i4 %r1287}1288 1289define i8 @known_reduce_or(<2 x i8> %xx) {1290; CHECK-LABEL: @known_reduce_or(1291; CHECK-NEXT:    ret i8 11292;1293  %x = or <2 x i8> %xx, <i8 5, i8 3>1294  %v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)1295  %r = and i8 %v, 11296  ret i8 %r1297}1298 1299define i8 @known_reduce_or_fail(<2 x i8> %xx) {1300; CHECK-LABEL: @known_reduce_or_fail(1301; CHECK-NEXT:    [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>1302; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])1303; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 41304; CHECK-NEXT:    ret i8 [[R]]1305;1306  %x = or <2 x i8> %xx, <i8 5, i8 3>1307  %v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)1308  %r = and i8 %v, 41309  ret i8 %r1310}1311 1312define i8 @known_reduce_and(<2 x i8> %xx) {1313; CHECK-LABEL: @known_reduce_and(1314; CHECK-NEXT:    ret i8 11315;1316  %x = or <2 x i8> %xx, <i8 5, i8 3>1317  %v = call i8 @llvm.vector.reduce.and(<2 x i8> %x)1318  %r = and i8 %v, 11319  ret i8 %r1320}1321 1322define i8 @known_reduce_and_fail(<2 x i8> %xx) {1323; CHECK-LABEL: @known_reduce_and_fail(1324; CHECK-NEXT:    [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>1325; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.and.v2i8(<2 x i8> [[X]])1326; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 21327; CHECK-NEXT:    ret i8 [[R]]1328;1329  %x = or <2 x i8> %xx, <i8 5, i8 3>1330  %v = call i8 @llvm.vector.reduce.and(<2 x i8> %x)1331  %r = and i8 %v, 21332  ret i8 %r1333}1334 1335define i8 @known_reduce_xor_even(<2 x i8> %xx) {1336; CHECK-LABEL: @known_reduce_xor_even(1337; CHECK-NEXT:    ret i8 01338;1339  %x = or <2 x i8> %xx, <i8 5, i8 3>1340  %v = call i8 @llvm.vector.reduce.xor(<2 x i8> %x)1341  %r = and i8 %v, 11342  ret i8 %r1343}1344 1345define i8 @known_reduce_xor_even2(<2 x i8> %xx) {1346; CHECK-LABEL: @known_reduce_xor_even2(1347; CHECK-NEXT:    ret i8 01348;1349  %x = and <2 x i8> %xx, <i8 15, i8 15>1350  %v = call i8 @llvm.vector.reduce.xor(<2 x i8> %x)1351  %r = and i8 %v, 161352  ret i8 %r1353}1354 1355define i8 @known_reduce_xor_even_fail(<2 x i8> %xx) {1356; CHECK-LABEL: @known_reduce_xor_even_fail(1357; CHECK-NEXT:    [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>1358; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.xor.v2i8(<2 x i8> [[X]])1359; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 21360; CHECK-NEXT:    ret i8 [[R]]1361;1362  %x = or <2 x i8> %xx, <i8 5, i8 3>1363  %v = call i8 @llvm.vector.reduce.xor(<2 x i8> %x)1364  %r = and i8 %v, 21365  ret i8 %r1366}1367 1368define i8 @known_reduce_xor_odd(<3 x i8> %xx) {1369; CHECK-LABEL: @known_reduce_xor_odd(1370; CHECK-NEXT:    ret i8 11371;1372  %x = or <3 x i8> %xx, <i8 5, i8 3, i8 9>1373  %v = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> %x)1374  %r = and i8 %v, 11375  ret i8 %r1376}1377 1378define i8 @known_reduce_xor_odd2(<3 x i8> %xx) {1379; CHECK-LABEL: @known_reduce_xor_odd2(1380; CHECK-NEXT:    ret i8 01381;1382  %x = and <3 x i8> %xx, <i8 15, i8 15, i8 31>1383  %v = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> %x)1384  %r = and i8 %v, 321385  ret i8 %r1386}1387 1388define i8 @known_reduce_xor_odd2_fail(<3 x i8> %xx) {1389; CHECK-LABEL: @known_reduce_xor_odd2_fail(1390; CHECK-NEXT:    [[X:%.*]] = and <3 x i8> [[XX:%.*]], <i8 15, i8 15, i8 31>1391; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> [[X]])1392; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 161393; CHECK-NEXT:    ret i8 [[R]]1394;1395  %x = and <3 x i8> %xx, <i8 15, i8 15, i8 31>1396  %v = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> %x)1397  %r = and i8 %v, 161398  ret i8 %r1399}1400 1401define i8 @known_reduce_xor_odd_fail(<3 x i8> %xx) {1402; CHECK-LABEL: @known_reduce_xor_odd_fail(1403; CHECK-NEXT:    [[X:%.*]] = or <3 x i8> [[XX:%.*]], <i8 5, i8 3, i8 9>1404; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> [[X]])1405; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 21406; CHECK-NEXT:    ret i8 [[R]]1407;1408  %x = or <3 x i8> %xx, <i8 5, i8 3, i8 9>1409  %v = call i8 @llvm.vector.reduce.xor.v3i8(<3 x i8> %x)1410  %r = and i8 %v, 21411  ret i8 %r1412}1413 1414define i8 @nonzero_reduce_xor_vscale_even(<vscale x 2 x i8> %xx) {1415; CHECK-LABEL: @nonzero_reduce_xor_vscale_even(1416; CHECK-NEXT:    ret i8 01417;1418  %one = insertelement <vscale x 2 x i8> poison, i8 1, i64 01419  %ones = shufflevector <vscale x 2 x i8> %one, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer1420  %x = or <vscale x 2 x i8> %xx, %ones1421  %v = call i8 @llvm.vector.reduce.xor.nxv2i8(<vscale x 2 x i8> %x)1422  %r = and i8 %v, 11423  ret i8 %r1424}1425 1426define i8 @nonzero_reduce_xor_vscale_odd_fail(<vscale x 3 x i8> %xx) {1427; CHECK-LABEL: @nonzero_reduce_xor_vscale_odd_fail(1428; CHECK-NEXT:    [[X:%.*]] = or <vscale x 3 x i8> [[XX:%.*]], splat (i8 1)1429; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.xor.nxv3i8(<vscale x 3 x i8> [[X]])1430; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 11431; CHECK-NEXT:    ret i8 [[R]]1432;1433  %one = insertelement <vscale x 3 x i8> poison, i8 1, i64 01434  %ones = shufflevector <vscale x 3 x i8> %one, <vscale x 3 x i8> poison, <vscale x 3 x i32> zeroinitializer1435  %x = or <vscale x 3 x i8> %xx, %ones1436  %v = call i8 @llvm.vector.reduce.xor.nxv3i8(<vscale x 3 x i8> %x)1437  %r = and i8 %v, 11438  ret i8 %r1439}1440 1441define i8 @nonzero_reduce_xor_vscale_even_fail(<vscale x 2 x i8> %xx) {1442; CHECK-LABEL: @nonzero_reduce_xor_vscale_even_fail(1443; CHECK-NEXT:    [[X:%.*]] = or <vscale x 2 x i8> [[XX:%.*]], splat (i8 1)1444; CHECK-NEXT:    [[V:%.*]] = call i8 @llvm.vector.reduce.xor.nxv2i8(<vscale x 2 x i8> [[X]])1445; CHECK-NEXT:    [[R:%.*]] = and i8 [[V]], 21446; CHECK-NEXT:    ret i8 [[R]]1447;1448  %one = insertelement <vscale x 2 x i8> poison, i8 1, i64 01449  %ones = shufflevector <vscale x 2 x i8> %one, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer1450  %x = or <vscale x 2 x i8> %xx, %ones1451  %v = call i8 @llvm.vector.reduce.xor.nxv2i8(<vscale x 2 x i8> %x)1452  %r = and i8 %v, 21453  ret i8 %r1454}1455 1456define i8 @nonzero_reduce_xor_vscale_odd(<vscale x 3 x i8> %xx) {1457; CHECK-LABEL: @nonzero_reduce_xor_vscale_odd(1458; CHECK-NEXT:    ret i8 01459;1460  %one = insertelement <vscale x 3 x i8> poison, i8 1, i64 01461  %ones = shufflevector <vscale x 3 x i8> %one, <vscale x 3 x i8> poison, <vscale x 3 x i32> zeroinitializer1462  %x = and <vscale x 3 x i8> %xx, %ones1463  %v = call i8 @llvm.vector.reduce.xor.nxv3i8(<vscale x 3 x i8> %x)1464  %r = and i8 %v, 21465  ret i8 %r1466}1467 1468define i1 @test_sign_pos(float %x) {1469; CHECK-LABEL: @test_sign_pos(1470; CHECK-NEXT:    ret i1 true1471;1472  %fabs = call float @llvm.fabs.f32(float %x)1473  %y = bitcast float %fabs to i321474  %sign = icmp sgt i32 %y, -11475  ret i1 %sign1476}1477 1478define i1 @test_sign_pos_half(half %x) {1479; CHECK-LABEL: @test_sign_pos_half(1480; CHECK-NEXT:    ret i1 true1481;1482  %fabs = call half @llvm.fabs.f16(half %x)1483  %y = bitcast half %fabs to i161484  %sign = icmp sgt i16 %y, -11485  ret i1 %sign1486}1487 1488define i1 @test_sign_pos_half_non_elementwise(<2 x half> %x) {1489; CHECK-LABEL: @test_sign_pos_half_non_elementwise(1490; CHECK-NEXT:    [[FABS:%.*]] = call <2 x half> @llvm.fabs.v2f16(<2 x half> [[X:%.*]])1491; CHECK-NEXT:    [[Y:%.*]] = bitcast <2 x half> [[FABS]] to i321492; CHECK-NEXT:    [[SIGN:%.*]] = icmp sgt i32 [[Y]], -11493; CHECK-NEXT:    ret i1 [[SIGN]]1494;1495  %fabs = call <2 x half> @llvm.fabs.v2f16(<2 x half> %x)1496  %y = bitcast <2 x half> %fabs to i321497  %sign = icmp sgt i32 %y, -11498  ret i1 %sign1499}1500 1501define i1 @test_sign_neg(float %x) {1502; CHECK-LABEL: @test_sign_neg(1503; CHECK-NEXT:    ret i1 true1504;1505  %fabs = call float @llvm.fabs.f32(float %x)1506  %fnabs = fneg float %fabs1507  %y = bitcast float %fnabs to i321508  %sign = icmp slt i32 %y, 01509  ret i1 %sign1510}1511 1512define <2 x i1> @test_sign_pos_vec(<2 x float> %x) {1513; CHECK-LABEL: @test_sign_pos_vec(1514; CHECK-NEXT:    ret <2 x i1> zeroinitializer1515;1516  %fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)1517  %y = bitcast <2 x float> %fabs to <2 x i32>1518  %sign = icmp slt <2 x i32> %y, zeroinitializer1519  ret <2 x i1> %sign1520}1521 1522define i32 @test_inf_only(float nofpclass(nan sub norm zero) %x) {1523; CHECK-LABEL: @test_inf_only(1524; CHECK-NEXT:    ret i32 21390950401525;1526  %y = bitcast float %x to i321527  %and = and i32 %y, 21474836471528  ret i32 %and1529}1530 1531define i16 @test_inf_only_bfloat(bfloat nofpclass(nan sub norm zero) %x) {1532; CHECK-LABEL: @test_inf_only_bfloat(1533; CHECK-NEXT:    ret i16 326401534;1535  %y = bitcast bfloat %x to i161536  %and = and i16 %y, 327671537  ret i16 %and1538}1539 1540define i128 @test_inf_only_ppc_fp128(ppc_fp128 nofpclass(nan sub norm zero) %x) {1541; CHECK-LABEL: @test_inf_only_ppc_fp128(1542; CHECK-NEXT:    ret i128 92188684372274053121543;1544  %y = bitcast ppc_fp128 %x to i1281545  %and = and i128 %y, 1701411834604692317316873037158841057271546  ret i128 %and1547}1548 1549define i32 @test_zero_only(float nofpclass(nan sub norm inf) %x) {1550; CHECK-LABEL: @test_zero_only(1551; CHECK-NEXT:    ret i32 01552;1553  %y = bitcast float %x to i321554  %and = and i32 %y, 21474836471555  ret i32 %and1556}1557 1558define i80 @test_zero_only_non_ieee(x86_fp80 nofpclass(nan sub norm inf) %x) {1559; CHECK-LABEL: @test_zero_only_non_ieee(1560; CHECK-NEXT:    ret i80 01561;1562  %y = bitcast x86_fp80 %x to i801563  %and = and i80 %y, 6044629098073145873530871564  ret i80 %and1565}1566 1567define i32 @test_inf_nan_only(float nofpclass(sub norm zero) %x) {1568; CHECK-LABEL: @test_inf_nan_only(1569; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321570; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 21307064321571; CHECK-NEXT:    ret i32 [[AND]]1572;1573  %y = bitcast float %x to i321574  %and = and i32 %y, 21307064321575  ret i32 %and1576}1577 1578define i32 @test_sub_zero_only(float nofpclass(nan norm inf) %x) {1579; CHECK-LABEL: @test_sub_zero_only(1580; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321581; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 21307064321582; CHECK-NEXT:    ret i32 [[AND]]1583;1584  %y = bitcast float %x to i321585  %and = and i32 %y, 21307064321586  ret i32 %and1587}1588 1589define i32 @test_inf_zero_only(float nofpclass(nan norm sub) %x) {1590; CHECK-LABEL: @test_inf_zero_only(1591; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321592; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 83886081593; CHECK-NEXT:    ret i32 [[AND]]1594;1595  %y = bitcast float %x to i321596  %and = and i32 %y, 167772151597  ret i32 %and1598}1599 1600; Make sure that the signbit is cleared.1601define i32 @test_ninf_only(double %x) {1602; CHECK-LABEL: @test_ninf_only(1603; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq double [[X:%.*]], 0xFFF00000000000001604; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1605; CHECK:       if.then:1606; CHECK-NEXT:    ret i32 01607; CHECK:       if.else:1608; CHECK-NEXT:    ret i32 01609;1610  %cmp = fcmp oeq double %x, 0xFFF00000000000001611  br i1 %cmp, label %if.then, label %if.else1612 1613if.then:1614  %cast = bitcast double %x to i641615  %trunc = trunc i64 %cast to i321616  ret i32 %trunc1617 1618if.else:1619  ret i32 01620}1621 1622define i1 @test_simplify_icmp(i32 %x) {1623; CHECK-LABEL: @test_simplify_icmp(1624; CHECK-NEXT:    ret i1 false1625;1626  %cast1 = uitofp i32 %x to double1627  %cast2 = bitcast double %cast1 to i641628  %mask = and i64 %cast2, -1407374883553281629  %cmp = icmp eq i64 %mask, -19703248369745921630  ret i1 %cmp1631}1632 1633define i32 @test_snan_quiet_bit1(float nofpclass(sub norm inf qnan) %x) {1634; CHECK-LABEL: @test_snan_quiet_bit1(1635; CHECK-NEXT:    [[BITS:%.*]] = bitcast float [[X:%.*]] to i321636; CHECK-NEXT:    [[MASKED:%.*]] = and i32 [[BITS]], 41943041637; CHECK-NEXT:    ret i32 [[MASKED]]1638;1639  %bits = bitcast float %x to i321640  %masked = and i32 %bits, 41943041641  ret i32 %masked1642}1643 1644define i32 @test_snan_quiet_bit2(float nofpclass(sub norm inf qnan) %x) {1645; CHECK-LABEL: @test_snan_quiet_bit2(1646; CHECK-NEXT:    [[BITS:%.*]] = bitcast float [[X:%.*]] to i321647; CHECK-NEXT:    [[MASKED:%.*]] = and i32 [[BITS]], 20971521648; CHECK-NEXT:    ret i32 [[MASKED]]1649;1650  %bits = bitcast float %x to i321651  %masked = and i32 %bits, 20971521652  ret i32 %masked1653}1654 1655define i32 @test_qnan_quiet_bit1(float nofpclass(sub norm inf snan) %x) {1656; CHECK-LABEL: @test_qnan_quiet_bit1(1657; CHECK-NEXT:    [[BITS:%.*]] = bitcast float [[X:%.*]] to i321658; CHECK-NEXT:    [[MASKED:%.*]] = and i32 [[BITS]], 41943041659; CHECK-NEXT:    ret i32 [[MASKED]]1660;1661  %bits = bitcast float %x to i321662  %masked = and i32 %bits, 41943041663  ret i32 %masked1664}1665 1666define i32 @test_qnan_quiet_bit2(float nofpclass(sub norm inf snan) %x) {1667; CHECK-LABEL: @test_qnan_quiet_bit2(1668; CHECK-NEXT:    [[BITS:%.*]] = bitcast float [[X:%.*]] to i321669; CHECK-NEXT:    [[MASKED:%.*]] = and i32 [[BITS]], 20971521670; CHECK-NEXT:    ret i32 [[MASKED]]1671;1672  %bits = bitcast float %x to i321673  %masked = and i32 %bits, 20971521674  ret i32 %masked1675}1676 1677define i16 @test_simplify_mask(i32 %ui, float %x) {1678; CHECK-LABEL: @test_simplify_mask(1679; CHECK-NEXT:    [[CONV:%.*]] = uitofp i32 [[UI:%.*]] to float1680; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[X:%.*]], [[CONV]]1681; CHECK-NEXT:    br i1 [[CMP]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]1682; CHECK:       if.end:1683; CHECK-NEXT:    ret i16 317441684; CHECK:       if.else:1685; CHECK-NEXT:    ret i16 01686;1687  %conv = uitofp i32 %ui to float1688  %cmp = fcmp olt float %x, %conv1689  br i1 %cmp, label %if.else, label %if.end1690 1691if.end:1692  %cast = bitcast float %conv to i321693  %shr = lshr i32 %cast, 161694  %trunc = trunc i32 %shr to i161695  %and = and i16 %trunc, -327681696  %or = or disjoint i16 %and, 317441697  ret i16 %or1698 1699if.else:1700  ret i16 01701}1702 1703define i1 @test_simplify_icmp2(double %x) {1704; CHECK-LABEL: @test_simplify_icmp2(1705; CHECK-NEXT:    [[ABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])1706; CHECK-NEXT:    [[COND:%.*]] = fcmp oeq double [[ABS]], 0x7FF00000000000001707; CHECK-NEXT:    br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1708; CHECK:       if.then:1709; CHECK-NEXT:    ret i1 false1710; CHECK:       if.else:1711; CHECK-NEXT:    ret i1 false1712;1713  %abs = tail call double @llvm.fabs.f64(double %x)1714  %cond = fcmp oeq double %abs, 0x7FF00000000000001715  br i1 %cond, label %if.then, label %if.else1716 1717if.then:1718  %cast = bitcast double %x to i641719  %cmp = icmp eq i64 %cast, 34587645138205409281720  ret i1 %cmp1721 1722if.else:1723  ret i1 false1724}1725 1726define i32 @test_snan_only(float nofpclass(qnan sub norm zero inf) %x) {1727; CHECK-LABEL: @test_snan_only(1728; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321729; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 41943041730; CHECK-NEXT:    ret i32 [[AND]]1731;1732  %y = bitcast float %x to i321733  %and = and i32 %y, 41943041734  ret i32 %and1735}1736 1737define i32 @test_qnan_only(float nofpclass(snan sub norm zero inf) %x) {1738; CHECK-LABEL: @test_qnan_only(1739; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321740; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 41943041741; CHECK-NEXT:    ret i32 [[AND]]1742;1743  %y = bitcast float %x to i321744  %and = and i32 %y, 41943041745  ret i32 %and1746}1747 1748; Make sure that we don't crash when the use of x is unreachable.1749define i64 @pr92084(double %x) {1750; CHECK-LABEL: @pr92084(1751; CHECK-NEXT:    [[CMP:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+001752; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_ELSE:%.*]]1753; CHECK:       if.then1:1754; CHECK-NEXT:    br i1 true, label [[IF_ELSE]], label [[IF_THEN2:%.*]]1755; CHECK:       if.then2:1756; CHECK-NEXT:    ret i64 poison1757; CHECK:       if.else:1758; CHECK-NEXT:    ret i64 01759;1760  %cmp = fcmp uno double %x, 0.000000e+001761  br i1 %cmp, label %if.then1, label %if.else1762 1763if.then1:1764  br i1 %cmp, label %if.else, label %if.then21765 1766if.then2:1767  %cast = bitcast double %x to i641768  %and = and i64 %cast, 11769  ret i64 %and1770 1771if.else:1772  ret i64 01773}1774 1775define i32 @test_none(float nofpclass(all) %x) {1776; CHECK-LABEL: @test_none(1777; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X:%.*]] to i321778; CHECK-NEXT:    [[AND:%.*]] = and i32 [[Y]], 41943041779; CHECK-NEXT:    ret i32 [[AND]]1780;1781  %y = bitcast float %x to i321782  %and = and i32 %y, 41943041783  ret i32 %and1784}1785 1786; We cannot make assumptions about the sign of result of sqrt1787; when the input is a negative value (except for -0).1788define i1 @pr92217() {1789; CHECK-LABEL: @pr92217(1790; CHECK-NEXT:    [[X:%.*]] = call float @llvm.sqrt.f32(float 0xC6DEBE9E60000000)1791; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X]] to i321792; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[Y]], 01793; CHECK-NEXT:    ret i1 [[CMP]]1794;1795  %x = call float @llvm.sqrt.f32(float 0xC6DEBE9E60000000)1796  %y = bitcast float %x to i321797  %cmp = icmp slt i32 %y, 01798  ret i1 %cmp1799}1800 1801define i1 @sqrt_negative_input(float nofpclass(nan zero pnorm psub pinf) %a) {1802; CHECK-LABEL: @sqrt_negative_input(1803; CHECK-NEXT:    [[X:%.*]] = call float @llvm.sqrt.f32(float [[A:%.*]])1804; CHECK-NEXT:    [[Y:%.*]] = bitcast float [[X]] to i321805; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[Y]], 01806; CHECK-NEXT:    ret i1 [[CMP]]1807;1808  %x = call float @llvm.sqrt.f32(float %a)1809  %y = bitcast float %x to i321810  %cmp = icmp slt i32 %y, 01811  ret i1 %cmp1812}1813 1814define i1 @sqrt_negative_input_nnan(float nofpclass(nan zero pnorm psub pinf) %a) {1815; CHECK-LABEL: @sqrt_negative_input_nnan(1816; CHECK-NEXT:    ret i1 false1817;1818  %x = call nnan float @llvm.sqrt.f32(float %a)1819  %y = bitcast float %x to i321820  %cmp = icmp slt i32 %y, 01821  ret i1 %cmp1822}1823 1824define i8 @test_icmp_add(i8 %n, i8 %n2, i8 %other) {1825; CHECK-LABEL: @test_icmp_add(1826; CHECK-NEXT:  entry:1827; CHECK-NEXT:    [[N_ADD:%.*]] = add nuw i8 [[N:%.*]], [[N2:%.*]]1828; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_ADD]], 321829; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1830; CHECK:       if.then:1831; CHECK-NEXT:    ret i8 01832; CHECK:       if.else:1833; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1834;1835entry:1836  %n_add = add nuw i8 %n, %n21837  %cmp = icmp ult i8 %n_add, 321838  br i1 %cmp, label %if.then, label %if.else1839 1840if.then:1841  %r = and i8 %n, 321842  ret i8 %r1843 1844if.else:1845  ret i8 %other1846}1847 1848define i8 @test_icmp_add_fail_nsw(i8 %n, i8 %n2, i8 %other) {1849; CHECK-LABEL: @test_icmp_add_fail_nsw(1850; CHECK-NEXT:  entry:1851; CHECK-NEXT:    [[N_ADD:%.*]] = add nsw i8 [[N:%.*]], [[N2:%.*]]1852; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_ADD]], 321853; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1854; CHECK:       if.then:1855; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 321856; CHECK-NEXT:    ret i8 [[R]]1857; CHECK:       if.else:1858; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1859;1860entry:1861  %n_add = add nsw i8 %n, %n21862  %cmp = icmp ult i8 %n_add, 321863  br i1 %cmp, label %if.then, label %if.else1864 1865if.then:1866  %r = and i8 %n, 321867  ret i8 %r1868 1869if.else:1870  ret i8 %other1871}1872 1873define i8 @test_icmp_add2(i8 %n, i8 %n2, i8 %other) {1874; CHECK-LABEL: @test_icmp_add2(1875; CHECK-NEXT:  entry:1876; CHECK-NEXT:    [[N_ADD:%.*]] = add nuw nsw i8 [[N:%.*]], [[N2:%.*]]1877; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_ADD]], 141878; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1879; CHECK:       if.then:1880; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1881; CHECK:       if.else:1882; CHECK-NEXT:    ret i8 01883;1884entry:1885  %n_add = add nsw nuw i8 %n, %n21886  %cmp = icmp uge i8 %n_add, 151887  br i1 %cmp, label %if.then, label %if.else1888 1889if.then:1890  ret i8 %other1891if.else:1892  %r = and i8 %n, 321893  ret i8 %r1894 1895}1896 1897define i8 @test_icmp_add_fail_bad_range(i8 %n, i8 %n2, i8 %other) {1898; CHECK-LABEL: @test_icmp_add_fail_bad_range(1899; CHECK-NEXT:  entry:1900; CHECK-NEXT:    [[N_ADD:%.*]] = add nuw i8 [[N:%.*]], [[N2:%.*]]1901; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_ADD]], 331902; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1903; CHECK:       if.then:1904; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 321905; CHECK-NEXT:    ret i8 [[R]]1906; CHECK:       if.else:1907; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1908;1909entry:1910  %n_add = add nuw i8 %n, %n21911  %cmp = icmp ule i8 %n_add, 321912  br i1 %cmp, label %if.then, label %if.else1913 1914if.then:1915  %r = and i8 %n, 321916  ret i8 %r1917 1918if.else:1919  ret i8 %other1920}1921 1922define i8 @test_icmp_add_fail_bad_pred(i8 %n, i8 %n2, i8 %other) {1923; CHECK-LABEL: @test_icmp_add_fail_bad_pred(1924; CHECK-NEXT:  entry:1925; CHECK-NEXT:    [[N_ADD:%.*]] = add nuw i8 [[N:%.*]], [[N2:%.*]]1926; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_ADD]], 321927; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1928; CHECK:       if.then:1929; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 321930; CHECK-NEXT:    ret i8 [[R]]1931; CHECK:       if.else:1932; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1933;1934entry:1935  %n_add = add nuw i8 %n, %n21936  %cmp = icmp ugt i8 %n_add, 321937  br i1 %cmp, label %if.then, label %if.else1938 1939if.then:1940  %r = and i8 %n, 321941  ret i8 %r1942 1943if.else:1944  ret i8 %other1945}1946 1947define i8 @test_icmp_sub(i8 %n, i8 %n2, i8 %other) {1948; CHECK-LABEL: @test_icmp_sub(1949; CHECK-NEXT:  entry:1950; CHECK-NEXT:    [[N_SUB:%.*]] = sub nuw i8 [[N:%.*]], [[N2:%.*]]1951; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_SUB]], -331952; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1953; CHECK:       if.then:1954; CHECK-NEXT:    ret i8 321955; CHECK:       if.else:1956; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1957;1958entry:1959  %n_sub = sub nuw i8 %n, %n21960  %cmp = icmp ugt i8 %n_sub, 2231961  br i1 %cmp, label %if.then, label %if.else1962 1963if.then:1964  %r = and i8 %n, 321965  ret i8 %r1966 1967if.else:1968  ret i8 %other1969}1970 1971define i8 @test_icmp_sub_fail_wrong_arg(i8 %n, i8 %n2, i8 %other) {1972; CHECK-LABEL: @test_icmp_sub_fail_wrong_arg(1973; CHECK-NEXT:  entry:1974; CHECK-NEXT:    [[N_SUB:%.*]] = sub nuw i8 [[N:%.*]], [[N2:%.*]]1975; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_SUB]], -331976; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]1977; CHECK:       if.then:1978; CHECK-NEXT:    [[R:%.*]] = and i8 [[N2]], 321979; CHECK-NEXT:    ret i8 [[R]]1980; CHECK:       if.else:1981; CHECK-NEXT:    ret i8 [[OTHER:%.*]]1982;1983entry:1984  %n_sub = sub nuw i8 %n, %n21985  %cmp = icmp ugt i8 %n_sub, 2231986  br i1 %cmp, label %if.then, label %if.else1987 1988if.then:1989  %r = and i8 %n2, 321990  ret i8 %r1991 1992if.else:1993  ret i8 %other1994}1995 1996define i8 @test_icmp_sub2(i8 %n, i8 %n2, i8 %other) {1997; CHECK-LABEL: @test_icmp_sub2(1998; CHECK-NEXT:  entry:1999; CHECK-NEXT:    [[N_SUB:%.*]] = sub nuw i8 [[N:%.*]], [[N2:%.*]]2000; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_SUB]], -312001; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2002; CHECK:       if.then:2003; CHECK-NEXT:    ret i8 [[OTHER:%.*]]2004; CHECK:       if.else:2005; CHECK-NEXT:    ret i8 322006;2007entry:2008  %n_sub = sub nuw i8 %n, %n22009  %cmp = icmp ule i8 %n_sub, 2242010  br i1 %cmp, label %if.then, label %if.else2011 2012if.then:2013  ret i8 %other2014if.else:2015  %r = and i8 %n, 322016  ret i8 %r2017 2018}2019 2020define i8 @test_icmp_sub2_fail_nsw(i8 %n, i8 %n2, i8 %other) {2021; CHECK-LABEL: @test_icmp_sub2_fail_nsw(2022; CHECK-NEXT:  entry:2023; CHECK-NEXT:    [[N_SUB:%.*]] = sub nsw i8 [[N:%.*]], [[N2:%.*]]2024; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i8 [[N_SUB]], -312025; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2026; CHECK:       if.then:2027; CHECK-NEXT:    ret i8 [[OTHER:%.*]]2028; CHECK:       if.else:2029; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 322030; CHECK-NEXT:    ret i8 [[R]]2031;2032entry:2033  %n_sub = sub nsw i8 %n, %n22034  %cmp = icmp ule i8 %n_sub, 2242035  br i1 %cmp, label %if.then, label %if.else2036 2037if.then:2038  ret i8 %other2039if.else:2040  %r = and i8 %n, 322041  ret i8 %r2042 2043}2044 2045 2046define i8 @test_icmp_sub_fail_bad_range(i8 %n, i8 %n2, i8 %other) {2047; CHECK-LABEL: @test_icmp_sub_fail_bad_range(2048; CHECK-NEXT:  entry:2049; CHECK-NEXT:    [[N_SUB:%.*]] = sub nuw i8 [[N:%.*]], [[N2:%.*]]2050; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i8 [[N_SUB]], -342051; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2052; CHECK:       if.then:2053; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 322054; CHECK-NEXT:    ret i8 [[R]]2055; CHECK:       if.else:2056; CHECK-NEXT:    ret i8 [[OTHER:%.*]]2057;2058entry:2059  %n_sub = sub nuw i8 %n, %n22060  %cmp = icmp uge i8 %n_sub, 2232061  br i1 %cmp, label %if.then, label %if.else2062 2063if.then:2064  %r = and i8 %n, 322065  ret i8 %r2066 2067if.else:2068  ret i8 %other2069}2070 2071define i8 @test_icmp_sub_fail_bad_pred(i8 %n, i8 %n2, i8 %other) {2072; CHECK-LABEL: @test_icmp_sub_fail_bad_pred(2073; CHECK-NEXT:  entry:2074; CHECK-NEXT:    [[N_SUB:%.*]] = sub nuw i8 [[N:%.*]], [[N2:%.*]]2075; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[N_SUB]], 312076; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2077; CHECK:       if.then:2078; CHECK-NEXT:    [[R:%.*]] = and i8 [[N]], 322079; CHECK-NEXT:    ret i8 [[R]]2080; CHECK:       if.else:2081; CHECK-NEXT:    ret i8 [[OTHER:%.*]]2082;2083entry:2084  %n_sub = sub nuw i8 %n, %n22085  %cmp = icmp sge i8 %n_sub, 322086  br i1 %cmp, label %if.then, label %if.else2087 2088if.then:2089  %r = and i8 %n, 322090  ret i8 %r2091 2092if.else:2093  ret i8 %other2094}2095 2096define i8 @simplifydemanded_context(i8 %x, i8 %y) {2097; CHECK-LABEL: @simplifydemanded_context(2098; CHECK-NEXT:    call void @dummy()2099; CHECK-NEXT:    [[X_LOBITS:%.*]] = and i8 [[X:%.*]], 32100; CHECK-NEXT:    [[PRECOND:%.*]] = icmp eq i8 [[X_LOBITS]], 02101; CHECK-NEXT:    call void @llvm.assume(i1 [[PRECOND]])2102; CHECK-NEXT:    ret i8 02103;2104  %and1 = and i8 %x, 12105  call void @dummy() ; may unwind2106  %x.lobits = and i8 %x, 32107  %precond = icmp eq i8 %x.lobits, 02108  call void @llvm.assume(i1 %precond)2109  %and2 = and i8 %and1, %y2110  ret i8 %and22111}2112 2113define i16 @pr97330(i1 %c, ptr %p1, ptr %p2) {2114; CHECK-LABEL: @pr97330(2115; CHECK-NEXT:  entry:2116; CHECK-NEXT:    br i1 [[C:%.*]], label [[EXIT:%.*]], label [[IF:%.*]]2117; CHECK:       if:2118; CHECK-NEXT:    unreachable2119; CHECK:       exit:2120; CHECK-NEXT:    [[V:%.*]] = load i64, ptr [[P1:%.*]], align 82121; CHECK-NEXT:    [[CONV:%.*]] = trunc i64 [[V]] to i162122; CHECK-NEXT:    ret i16 [[CONV]]2123;2124entry:2125  %v = load i64, ptr %p1, align 82126  %conv = trunc i64 %v to i162127  br i1 %c, label %exit, label %if2128 2129if:2130  %cmp = icmp ne i16 %conv, 12131  %conv2 = zext i1 %cmp to i322132  store i32 %conv2, ptr %p2, align 42133  %cmp2 = icmp eq i64 %v, 12134  call void @llvm.assume(i1 %cmp2)2135  unreachable2136 2137exit:2138  ret i16 %conv2139}2140 2141define i1 @mul_nuw_nsw_nonneg_const(i8 %x) {2142; CHECK-LABEL: @mul_nuw_nsw_nonneg_const(2143; CHECK-NEXT:    ret i1 true2144;2145  %mul = mul nuw nsw i8 %x, 32146  %cmp = icmp sgt i8 %mul, -12147  ret i1 %cmp2148}2149 2150define i1 @mul_nuw_nsw_nonneg_const_missing_nuw(i8 %x) {2151; CHECK-LABEL: @mul_nuw_nsw_nonneg_const_missing_nuw(2152; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -12153; CHECK-NEXT:    ret i1 [[CMP]]2154;2155  %mul = mul nsw i8 %x, 32156  %cmp = icmp sgt i8 %mul, -12157  ret i1 %cmp2158}2159 2160define i1 @mul_nuw_nsw_nonneg_const_missing_nsw(i8 %x) {2161; CHECK-LABEL: @mul_nuw_nsw_nonneg_const_missing_nsw(2162; CHECK-NEXT:    [[MUL:%.*]] = mul nuw i8 [[X:%.*]], 32163; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[MUL]], -12164; CHECK-NEXT:    ret i1 [[CMP]]2165;2166  %mul = mul nuw i8 %x, 32167  %cmp = icmp sgt i8 %mul, -12168  ret i1 %cmp2169}2170 2171define i1 @mul_nuw_nsw_nonneg_can_be_one(i8 %x, i8 %y) {2172; CHECK-LABEL: @mul_nuw_nsw_nonneg_can_be_one(2173; CHECK-NEXT:    [[Y_NNEG:%.*]] = and i8 [[Y:%.*]], 1272174; CHECK-NEXT:    [[MUL:%.*]] = mul nuw nsw i8 [[X:%.*]], [[Y_NNEG]]2175; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[MUL]], -12176; CHECK-NEXT:    ret i1 [[CMP]]2177;2178  %y.nneg = and i8 %y, 1272179  %mul = mul nuw nsw i8 %x, %y.nneg2180  %cmp = icmp sgt i8 %mul, -12181  ret i1 %cmp2182}2183 2184define i1 @mul_nuw_nsw_nonneg_cant_be_one(i8 %x, i8 %y) {2185; CHECK-LABEL: @mul_nuw_nsw_nonneg_cant_be_one(2186; CHECK-NEXT:    ret i1 true2187;2188  %y.nneg = and i8 %y, 1272189  %y.nneg.not.one = or i8 %y.nneg, 22190  %mul = mul nuw nsw i8 %x, %y.nneg.not.one2191  %cmp = icmp sgt i8 %mul, -12192  ret i1 %cmp2193}2194 2195define i1 @mul_nuw_nsw_nonneg_cant_be_one_commuted(i8 %x, i8 %y) {2196; CHECK-LABEL: @mul_nuw_nsw_nonneg_cant_be_one_commuted(2197; CHECK-NEXT:    ret i1 true2198;2199  %y.nneg = and i8 %y, 1272200  %y.nneg.not.one = or i8 %y.nneg, 22201  %mul = mul nuw nsw i8 %y.nneg.not.one, %x2202  %cmp = icmp sgt i8 %mul, -12203  ret i1 %cmp2204}2205 2206define i8 @test_trunc_and_1(i8 %a) {2207; CHECK-LABEL: @test_trunc_and_1(2208; CHECK-NEXT:  entry:2209; CHECK-NEXT:    [[CAST:%.*]] = trunc i8 [[A:%.*]] to i12210; CHECK-NEXT:    br i1 [[CAST]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2211; CHECK:       if.then:2212; CHECK-NEXT:    ret i8 12213; CHECK:       if.else:2214; CHECK-NEXT:    ret i8 02215;2216entry:2217  %cast = trunc i8 %a to i12218  br i1 %cast, label %if.then, label %if.else2219 2220if.then:2221  %b = and i8 %a, 12222  ret i8 %b2223 2224if.else:2225  %c = and i8 %a, 12226  ret i8 %c2227}2228 2229define i8 @test_not_trunc_and_1(i8 %a) {2230; CHECK-LABEL: @test_not_trunc_and_1(2231; CHECK-NEXT:  entry:2232; CHECK-NEXT:    [[CAST:%.*]] = trunc i8 [[A:%.*]] to i12233; CHECK-NEXT:    br i1 [[CAST]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]2234; CHECK:       if.then:2235; CHECK-NEXT:    ret i8 02236; CHECK:       if.else:2237; CHECK-NEXT:    ret i8 12238;2239entry:2240  %cast = trunc i8 %a to i12241  %not = xor i1 %cast, true2242  br i1 %not, label %if.then, label %if.else2243 2244if.then:2245  %b = and i8 %a, 12246  ret i8 %b2247 2248if.else:2249  %c = and i8 %a, 12250  ret i8 %c2251}2252 2253define i8 @neg_test_trunc_or_2(i8 %a) {2254; CHECK-LABEL: @neg_test_trunc_or_2(2255; CHECK-NEXT:  entry:2256; CHECK-NEXT:    [[CAST:%.*]] = trunc i8 [[A:%.*]] to i12257; CHECK-NEXT:    br i1 [[CAST]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]2258; CHECK:       if.then:2259; CHECK-NEXT:    [[B:%.*]] = or i8 [[A]], 22260; CHECK-NEXT:    ret i8 [[B]]2261; CHECK:       if.else:2262; CHECK-NEXT:    [[C:%.*]] = or i8 [[A]], 22263; CHECK-NEXT:    ret i8 [[C]]2264;2265entry:2266  %cast = trunc i8 %a to i12267  br i1 %cast, label %if.then, label %if.else2268 2269if.then:2270  %b = or i8 %a, 22271  ret i8 %b2272 2273if.else:2274  %c = or i8 %a, 22275  ret i8 %c2276}2277 2278define i8 @test_trunc_nuw_and_1(i8 %a) {2279; CHECK-LABEL: @test_trunc_nuw_and_1(2280; CHECK-NEXT:  entry:2281; CHECK-NEXT:    [[CAST:%.*]] = trunc nuw i8 [[A:%.*]] to i12282; CHECK-NEXT:    br i1 [[CAST]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]2283; CHECK:       if.then:2284; CHECK-NEXT:    ret i8 02285; CHECK:       if.else:2286; CHECK-NEXT:    ret i8 12287;2288entry:2289  %cast = trunc nuw i8 %a to i12290  br i1 %cast, label %if.else, label %if.then2291 2292if.then:2293  %b = and i8 %a, 12294  ret i8 %b2295 2296if.else:2297  %c = and i8 %a, 12298  ret i8 %c2299}2300 2301define i8 @test_trunc_nuw_or_2(i8 %a) {2302; CHECK-LABEL: @test_trunc_nuw_or_2(2303; CHECK-NEXT:  entry:2304; CHECK-NEXT:    [[CAST:%.*]] = trunc nuw i8 [[A:%.*]] to i12305; CHECK-NEXT:    br i1 [[CAST]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]2306; CHECK:       if.then:2307; CHECK-NEXT:    ret i8 22308; CHECK:       if.else:2309; CHECK-NEXT:    ret i8 32310;2311entry:2312  %cast = trunc nuw i8 %a to i12313  br i1 %cast, label %if.else, label %if.then2314 2315if.then:2316  %b = or i8 %a, 22317  ret i8 %b2318 2319if.else:2320  %c = or i8 %a, 22321  ret i8 %c2322}2323 2324define i8 @test_not_trunc_nuw_and_1(i8 %a) {2325; CHECK-LABEL: @test_not_trunc_nuw_and_1(2326; CHECK-NEXT:  entry:2327; CHECK-NEXT:    [[CAST:%.*]] = trunc nuw i8 [[A:%.*]] to i12328; CHECK-NEXT:    br i1 [[CAST]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]2329; CHECK:       if.then:2330; CHECK-NEXT:    ret i8 02331; CHECK:       if.else:2332; CHECK-NEXT:    ret i8 12333;2334entry:2335  %cast = trunc nuw i8 %a to i12336  %not = xor i1 %cast, true2337  br i1 %not, label %if.then, label %if.else2338 2339if.then:2340  %b = and i8 %a, 12341  ret i8 %b2342 2343if.else:2344  %c = and i8 %a, 12345  ret i8 %c2346}2347 2348define i8 @test_trunc_cond_and(i8 %x, i1 %c) {2349; CHECK-LABEL: @test_trunc_cond_and(2350; CHECK-NEXT:    [[CMP:%.*]] = trunc i8 [[X:%.*]] to i12351; CHECK-NEXT:    [[COND:%.*]] = and i1 [[C:%.*]], [[CMP]]2352; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]2353; CHECK:       if:2354; CHECK-NEXT:    ret i8 -12355; CHECK:       exit:2356; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -22357; CHECK-NEXT:    ret i8 [[OR2]]2358;2359  %cmp = trunc i8 %x to i12360  %cond = and i1 %cmp, %c2361  br i1 %cond, label %if, label %exit2362 2363if:2364  %or1 = or i8 %x, -22365  ret i8 %or12366 2367exit:2368  %or2 = or i8 %x, -22369  ret i8 %or22370}2371 2372define i8 @test_not_trunc_cond_and(i8 %x, i1 %c) {2373; CHECK-LABEL: @test_not_trunc_cond_and(2374; CHECK-NEXT:    [[CMP:%.*]] = trunc i8 [[X:%.*]] to i12375; CHECK-NEXT:    [[NOT:%.*]] = xor i1 [[CMP]], true2376; CHECK-NEXT:    [[COND:%.*]] = and i1 [[C:%.*]], [[NOT]]2377; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]2378; CHECK:       if:2379; CHECK-NEXT:    ret i8 -22380; CHECK:       exit:2381; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -22382; CHECK-NEXT:    ret i8 [[OR2]]2383;2384  %cmp = trunc i8 %x to i12385  %not = xor i1 %cmp, true2386  %cond = and i1 %not, %c2387  br i1 %cond, label %if, label %exit2388 2389if:2390  %or1 = or i8 %x, -22391  ret i8 %or12392 2393exit:2394  %or2 = or i8 %x, -22395  ret i8 %or22396}2397 2398define i8 @test_inv_cond_and(i8 %x, i1 %c) {2399; CHECK-LABEL: @test_inv_cond_and(2400; CHECK-NEXT:    [[AND:%.*]] = and i8 [[X:%.*]], 32401; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[AND]], 02402; CHECK-NEXT:    call void @use(i1 [[CMP]])2403; CHECK-NEXT:    [[NOT:%.*]] = xor i1 [[CMP]], true2404; CHECK-NEXT:    [[COND:%.*]] = and i1 [[C:%.*]], [[NOT]]2405; CHECK-NEXT:    br i1 [[COND]], label [[IF:%.*]], label [[EXIT:%.*]]2406; CHECK:       if:2407; CHECK-NEXT:    ret i8 -42408; CHECK:       exit:2409; CHECK-NEXT:    [[OR2:%.*]] = or i8 [[X]], -42410; CHECK-NEXT:    ret i8 [[OR2]]2411;2412  %and = and i8 %x, 32413  %cmp = icmp ne i8 %and, 02414  call void @use(i1 %cmp)2415  %not = xor i1 %cmp, true2416  %cond = and i1 %not, %c2417  br i1 %cond, label %if, label %exit2418 2419if:2420  %or1 = or i8 %x, -42421  ret i8 %or12422 2423exit:2424  %or2 = or i8 %x, -42425  ret i8 %or22426}2427 2428declare void @dummy()2429declare void @use(i1)2430declare void @sink(i8)2431