1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4declare void @use1(i1) 5declare void @use8(i8) 6 7define i32 @test1(i32 %A) { 8; CHECK-LABEL: @test1( 9; CHECK-NEXT: ret i32 [[A:%.*]] 10; 11 %B = xor i32 %A, -1 12 %C = xor i32 %B, -1 13 ret i32 %C 14} 15 16define i1 @invert_icmp(i32 %A, i32 %B) { 17; CHECK-LABEL: @invert_icmp( 18; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp sgt i32 [[A:%.*]], [[B:%.*]] 19; CHECK-NEXT: ret i1 [[CMP_NOT]] 20; 21 %cmp = icmp sle i32 %A, %B 22 %not = xor i1 %cmp, true 23 ret i1 %not 24} 25 26; PR1570 27 28define i1 @invert_fcmp(float %X, float %Y) { 29; CHECK-LABEL: @invert_fcmp( 30; CHECK-NEXT: [[CMP:%.*]] = fcmp uge float [[X:%.*]], [[Y:%.*]] 31; CHECK-NEXT: ret i1 [[CMP]] 32; 33 %cmp = fcmp olt float %X, %Y 34 %not = xor i1 %cmp, true 35 ret i1 %not 36} 37 38; PR2298 39 40define i1 @not_not_cmp(i32 %a, i32 %b) { 41; CHECK-LABEL: @not_not_cmp( 42; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[B:%.*]], [[A:%.*]] 43; CHECK-NEXT: ret i1 [[CMP]] 44; 45 %nota = xor i32 %a, -1 46 %notb = xor i32 %b, -1 47 %cmp = icmp slt i32 %nota, %notb 48 ret i1 %cmp 49} 50 51define <2 x i1> @not_not_cmp_vector(<2 x i32> %a, <2 x i32> %b) { 52; CHECK-LABEL: @not_not_cmp_vector( 53; CHECK-NEXT: [[CMP:%.*]] = icmp ugt <2 x i32> [[B:%.*]], [[A:%.*]] 54; CHECK-NEXT: ret <2 x i1> [[CMP]] 55; 56 %nota = xor <2 x i32> %a, <i32 -1, i32 -1> 57 %notb = xor <2 x i32> %b, <i32 -1, i32 -1> 58 %cmp = icmp ugt <2 x i32> %nota, %notb 59 ret <2 x i1> %cmp 60} 61 62define i1 @not_cmp_constant(i32 %a) { 63; CHECK-LABEL: @not_cmp_constant( 64; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], -43 65; CHECK-NEXT: ret i1 [[CMP]] 66; 67 %nota = xor i32 %a, -1 68 %cmp = icmp ugt i32 %nota, 42 69 ret i1 %cmp 70} 71 72define <2 x i1> @not_cmp_constant_vector(<2 x i32> %a) { 73; CHECK-LABEL: @not_cmp_constant_vector( 74; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> [[A:%.*]], <i32 -43, i32 -43> 75; CHECK-NEXT: ret <2 x i1> [[CMP]] 76; 77 %nota = xor <2 x i32> %a, <i32 -1, i32 -1> 78 %cmp = icmp slt <2 x i32> %nota, <i32 42, i32 42> 79 ret <2 x i1> %cmp 80} 81 82define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) { 83; CHECK-LABEL: @test7( 84; CHECK-NEXT: [[COND_NOT:%.*]] = icmp sgt <2 x i32> [[A:%.*]], [[B:%.*]] 85; CHECK-NEXT: ret <2 x i1> [[COND_NOT]] 86; 87 %cond = icmp sle <2 x i32> %A, %B 88 %Ret = xor <2 x i1> %cond, <i1 true, i1 true> 89 ret <2 x i1> %Ret 90} 91 92define i32 @not_ashr_not(i32 %A, i32 %B) { 93; CHECK-LABEL: @not_ashr_not( 94; CHECK-NEXT: [[NOT1_NOT:%.*]] = ashr i32 [[A:%.*]], [[B:%.*]] 95; CHECK-NEXT: ret i32 [[NOT1_NOT]] 96; 97 %not1 = xor i32 %A, -1 98 %ashr = ashr i32 %not1, %B 99 %not2 = xor i32 %ashr, -1 100 ret i32 %not2 101} 102 103define i8 @not_ashr_const(i8 %x) { 104; CHECK-LABEL: @not_ashr_const( 105; CHECK-NEXT: [[NOT:%.*]] = lshr i8 41, [[X:%.*]] 106; CHECK-NEXT: ret i8 [[NOT]] 107; 108 %shr = ashr i8 -42, %x 109 %not = xor i8 %shr, -1 110 ret i8 %not 111} 112 113define <2 x i8> @not_ashr_const_splat(<2 x i8> %x) { 114; CHECK-LABEL: @not_ashr_const_splat( 115; CHECK-NEXT: [[NOT:%.*]] = lshr <2 x i8> <i8 41, i8 41>, [[X:%.*]] 116; CHECK-NEXT: ret <2 x i8> [[NOT]] 117; 118 %shr = ashr <2 x i8> <i8 -42, i8 -42>, %x 119 %not = xor <2 x i8> %shr, <i8 -1, i8 -1> 120 ret <2 x i8> %not 121} 122 123; We can't get rid of the 'not' on a logical shift of a negative constant. 124 125define i8 @not_lshr_const_negative(i8 %x) { 126; CHECK-LABEL: @not_lshr_const_negative( 127; CHECK-NEXT: [[SHR:%.*]] = lshr i8 -42, [[X:%.*]] 128; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[SHR]], -1 129; CHECK-NEXT: ret i8 [[NOT]] 130; 131 %shr = lshr i8 -42, %x 132 %not = xor i8 %shr, -1 133 ret i8 %not 134} 135 136define i8 @not_lshr_const(i8 %x) { 137; CHECK-LABEL: @not_lshr_const( 138; CHECK-NEXT: [[NOT:%.*]] = ashr i8 -43, [[X:%.*]] 139; CHECK-NEXT: ret i8 [[NOT]] 140; 141 %shr = lshr i8 42, %x 142 %not = xor i8 %shr, -1 143 ret i8 %not 144} 145 146define <2 x i8> @not_lshr_const_splat(<2 x i8> %x) { 147; CHECK-LABEL: @not_lshr_const_splat( 148; CHECK-NEXT: [[NOT:%.*]] = ashr <2 x i8> <i8 -43, i8 -43>, [[X:%.*]] 149; CHECK-NEXT: ret <2 x i8> [[NOT]] 150; 151 %shr = lshr <2 x i8> <i8 42, i8 42>, %x 152 %not = xor <2 x i8> %shr, <i8 -1, i8 -1> 153 ret <2 x i8> %not 154} 155 156define i32 @not_sub(i32 %y) { 157; CHECK-LABEL: @not_sub( 158; CHECK-NEXT: [[R:%.*]] = add i32 [[Y:%.*]], -124 159; CHECK-NEXT: ret i32 [[R]] 160; 161 %s = sub i32 123, %y 162 %r = xor i32 %s, -1 163 ret i32 %r 164} 165 166define i32 @not_sub_extra_use(i32 %y, i32* %p) { 167; CHECK-LABEL: @not_sub_extra_use( 168; CHECK-NEXT: [[S:%.*]] = sub i32 123, [[Y:%.*]] 169; CHECK-NEXT: store i32 [[S]], i32* [[P:%.*]], align 4 170; CHECK-NEXT: [[R:%.*]] = add i32 [[Y]], -124 171; CHECK-NEXT: ret i32 [[R]] 172; 173 %s = sub i32 123, %y 174 store i32 %s, i32* %p 175 %r = xor i32 %s, -1 176 ret i32 %r 177} 178 179define <2 x i32> @not_sub_splat(<2 x i32> %y) { 180; CHECK-LABEL: @not_sub_splat( 181; CHECK-NEXT: [[R:%.*]] = add <2 x i32> [[Y:%.*]], <i32 -124, i32 -124> 182; CHECK-NEXT: ret <2 x i32> [[R]] 183; 184 %s = sub <2 x i32> <i32 123, i32 123>, %y 185 %r = xor <2 x i32> %s, <i32 -1, i32 -1> 186 ret <2 x i32> %r 187} 188 189define <2 x i32> @not_sub_extra_use_splat(<2 x i32> %y, <2 x i32>* %p) { 190; CHECK-LABEL: @not_sub_extra_use_splat( 191; CHECK-NEXT: [[S:%.*]] = sub <2 x i32> <i32 123, i32 123>, [[Y:%.*]] 192; CHECK-NEXT: store <2 x i32> [[S]], <2 x i32>* [[P:%.*]], align 8 193; CHECK-NEXT: [[R:%.*]] = add <2 x i32> [[Y]], <i32 -124, i32 -124> 194; CHECK-NEXT: ret <2 x i32> [[R]] 195; 196 %s = sub <2 x i32> <i32 123, i32 123>, %y 197 store <2 x i32> %s, <2 x i32>* %p 198 %r = xor <2 x i32> %s, <i32 -1, i32 -1> 199 ret <2 x i32> %r 200} 201 202define <2 x i32> @not_sub_vec(<2 x i32> %y) { 203; CHECK-LABEL: @not_sub_vec( 204; CHECK-NEXT: [[R:%.*]] = add <2 x i32> [[Y:%.*]], <i32 -43, i32 -124> 205; CHECK-NEXT: ret <2 x i32> [[R]] 206; 207 %s = sub <2 x i32> <i32 42, i32 123>, %y 208 %r = xor <2 x i32> %s, <i32 -1, i32 -1> 209 ret <2 x i32> %r 210} 211 212define <2 x i32> @not_sub_extra_use_vec(<2 x i32> %y, <2 x i32>* %p) { 213; CHECK-LABEL: @not_sub_extra_use_vec( 214; CHECK-NEXT: [[S:%.*]] = sub <2 x i32> <i32 123, i32 42>, [[Y:%.*]] 215; CHECK-NEXT: store <2 x i32> [[S]], <2 x i32>* [[P:%.*]], align 8 216; CHECK-NEXT: [[R:%.*]] = add <2 x i32> [[Y]], <i32 -124, i32 -43> 217; CHECK-NEXT: ret <2 x i32> [[R]] 218; 219 %s = sub <2 x i32> <i32 123, i32 42>, %y 220 store <2 x i32> %s, <2 x i32>* %p 221 %r = xor <2 x i32> %s, <i32 -1, i32 -1> 222 ret <2 x i32> %r 223} 224 225; ~(X + C) --> -X - C - 1 --> -(C + 1) - X 226 227define i32 @not_add(i32 %x) { 228; CHECK-LABEL: @not_add( 229; CHECK-NEXT: [[R:%.*]] = sub i32 -124, [[X:%.*]] 230; CHECK-NEXT: ret i32 [[R]] 231; 232 %a = add i32 %x, 123 233 %r = xor i32 %a, -1 234 ret i32 %r 235} 236 237define <2 x i32> @not_add_splat(<2 x i32> %x) { 238; CHECK-LABEL: @not_add_splat( 239; CHECK-NEXT: [[R:%.*]] = sub <2 x i32> <i32 -124, i32 -124>, [[X:%.*]] 240; CHECK-NEXT: ret <2 x i32> [[R]] 241; 242 %a = add <2 x i32> %x, <i32 123, i32 123> 243 %r = xor <2 x i32> %a, <i32 -1, i32 -1> 244 ret <2 x i32> %r 245} 246 247define <2 x i32> @not_add_vec(<2 x i32> %x) { 248; CHECK-LABEL: @not_add_vec( 249; CHECK-NEXT: [[R:%.*]] = sub <2 x i32> <i32 -43, i32 -124>, [[X:%.*]] 250; CHECK-NEXT: ret <2 x i32> [[R]] 251; 252 %a = add <2 x i32> %x, <i32 42, i32 123> 253 %r = xor <2 x i32> %a, <i32 -1, i32 -1> 254 ret <2 x i32> %r 255} 256 257define i1 @not_select_cmp_cmp(i32 %x, i32 %y, float %z, float %w, i1 %cond) { 258; CHECK-LABEL: @not_select_cmp_cmp( 259; CHECK-NEXT: [[CMPT:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] 260; CHECK-NEXT: [[CMPF:%.*]] = fcmp ole float [[Z:%.*]], [[W:%.*]] 261; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[CMPF]] 262; CHECK-NEXT: ret i1 [[SEL]] 263; 264 %cmpt = icmp sle i32 %x, %y 265 %cmpf = fcmp ugt float %z, %w 266 %sel = select i1 %cond, i1 %cmpt, i1 %cmpf 267 %not = xor i1 %sel, true 268 ret i1 %not 269} 270 271; TODO: Missed canonicalization - hoist 'not'? 272 273define i1 @not_select_cmp_cmp_extra_use1(i32 %x, i32 %y, float %z, float %w, i1 %cond) { 274; CHECK-LABEL: @not_select_cmp_cmp_extra_use1( 275; CHECK-NEXT: [[CMPT:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]] 276; CHECK-NEXT: call void @use1(i1 [[CMPT]]) 277; CHECK-NEXT: [[CMPF:%.*]] = fcmp ugt float [[Z:%.*]], [[W:%.*]] 278; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[CMPF]] 279; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 280; CHECK-NEXT: ret i1 [[NOT]] 281; 282 %cmpt = icmp sle i32 %x, %y 283 call void @use1(i1 %cmpt) 284 %cmpf = fcmp ugt float %z, %w 285 %sel = select i1 %cond, i1 %cmpt, i1 %cmpf 286 %not = xor i1 %sel, true 287 ret i1 %not 288} 289 290; TODO: Missed canonicalization - hoist 'not'? 291 292define i1 @not_select_cmp_cmp_extra_use2(i32 %x, i32 %y, float %z, float %w, i1 %cond) { 293; CHECK-LABEL: @not_select_cmp_cmp_extra_use2( 294; CHECK-NEXT: [[CMPT:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]] 295; CHECK-NEXT: [[CMPF:%.*]] = fcmp ugt float [[Z:%.*]], [[W:%.*]] 296; CHECK-NEXT: call void @use1(i1 [[CMPF]]) 297; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[CMPF]] 298; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 299; CHECK-NEXT: ret i1 [[NOT]] 300; 301 %cmpt = icmp sle i32 %x, %y 302 %cmpf = fcmp ugt float %z, %w 303 call void @use1(i1 %cmpf) 304 %sel = select i1 %cond, i1 %cmpt, i1 %cmpf 305 %not = xor i1 %sel, true 306 ret i1 %not 307} 308 309; Negative test - extra uses would require more instructions. 310 311define i1 @not_select_cmp_cmp_extra_use3(i32 %x, i32 %y, float %z, float %w, i1 %cond) { 312; CHECK-LABEL: @not_select_cmp_cmp_extra_use3( 313; CHECK-NEXT: [[CMPT:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]] 314; CHECK-NEXT: call void @use1(i1 [[CMPT]]) 315; CHECK-NEXT: [[CMPF:%.*]] = fcmp ugt float [[Z:%.*]], [[W:%.*]] 316; CHECK-NEXT: call void @use1(i1 [[CMPF]]) 317; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[CMPF]] 318; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 319; CHECK-NEXT: ret i1 [[NOT]] 320; 321 %cmpt = icmp sle i32 %x, %y 322 call void @use1(i1 %cmpt) 323 %cmpf = fcmp ugt float %z, %w 324 call void @use1(i1 %cmpf) 325 %sel = select i1 %cond, i1 %cmpt, i1 %cmpf 326 %not = xor i1 %sel, true 327 ret i1 %not 328} 329 330; Negative test - extra uses would require more instructions. 331 332define i1 @not_select_cmp_cmp_extra_use4(i32 %x, i32 %y, float %z, float %w, i1 %cond) { 333; CHECK-LABEL: @not_select_cmp_cmp_extra_use4( 334; CHECK-NEXT: [[CMPT:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]] 335; CHECK-NEXT: [[CMPF:%.*]] = fcmp ugt float [[Z:%.*]], [[W:%.*]] 336; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[CMPF]] 337; CHECK-NEXT: call void @use1(i1 [[SEL]]) 338; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 339; CHECK-NEXT: ret i1 [[NOT]] 340; 341 %cmpt = icmp sle i32 %x, %y 342 %cmpf = fcmp ugt float %z, %w 343 %sel = select i1 %cond, i1 %cmpt, i1 %cmpf 344 call void @use1(i1 %sel) 345 %not = xor i1 %sel, true 346 ret i1 %not 347} 348 349; TODO: Missed canonicalization - hoist 'not'? 350 351define i1 @not_select_cmpt(double %x, double %y, i1 %z, i1 %cond) { 352; CHECK-LABEL: @not_select_cmpt( 353; CHECK-NEXT: [[CMPT:%.*]] = fcmp oeq double [[X:%.*]], [[Y:%.*]] 354; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[Z:%.*]] 355; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 356; CHECK-NEXT: ret i1 [[NOT]] 357; 358 %cmpt = fcmp oeq double %x, %y 359 %sel = select i1 %cond, i1 %cmpt, i1 %z 360 %not = xor i1 %sel, true 361 ret i1 %not 362} 363 364; TODO: Missed canonicalization - hoist 'not'? 365 366define i1 @not_select_cmpf(i1 %x, i32 %z, i32 %w, i1 %cond) { 367; CHECK-LABEL: @not_select_cmpf( 368; CHECK-NEXT: [[CMPF:%.*]] = icmp ugt i32 [[Z:%.*]], [[W:%.*]] 369; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[X:%.*]], i1 [[CMPF]] 370; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 371; CHECK-NEXT: ret i1 [[NOT]] 372; 373 %cmpf = icmp ugt i32 %z, %w 374 %sel = select i1 %cond, i1 %x, i1 %cmpf 375 %not = xor i1 %sel, true 376 ret i1 %not 377} 378 379define i1 @not_select_cmpt_extra_use(double %x, double %y, i1 %z, i1 %cond) { 380; CHECK-LABEL: @not_select_cmpt_extra_use( 381; CHECK-NEXT: [[CMPT:%.*]] = fcmp oeq double [[X:%.*]], [[Y:%.*]] 382; CHECK-NEXT: call void @use1(i1 [[CMPT]]) 383; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMPT]], i1 [[Z:%.*]] 384; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 385; CHECK-NEXT: ret i1 [[NOT]] 386; 387 %cmpt = fcmp oeq double %x, %y 388 call void @use1(i1 %cmpt) 389 %sel = select i1 %cond, i1 %cmpt, i1 %z 390 %not = xor i1 %sel, true 391 ret i1 %not 392} 393 394define i1 @not_select_cmpf_extra_use(i1 %x, i32 %z, i32 %w, i1 %cond) { 395; CHECK-LABEL: @not_select_cmpf_extra_use( 396; CHECK-NEXT: [[CMPF:%.*]] = icmp ugt i32 [[Z:%.*]], [[W:%.*]] 397; CHECK-NEXT: call void @use1(i1 [[CMPF]]) 398; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[X:%.*]], i1 [[CMPF]] 399; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[SEL]], true 400; CHECK-NEXT: ret i1 [[NOT]] 401; 402 %cmpf = icmp ugt i32 %z, %w 403 call void @use1(i1 %cmpf) 404 %sel = select i1 %cond, i1 %x, i1 %cmpf 405 %not = xor i1 %sel, true 406 ret i1 %not 407} 408 409define i8 @not_or_neg(i8 %x, i8 %y) { 410; CHECK-LABEL: @not_or_neg( 411; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[Y:%.*]], -1 412; CHECK-NEXT: [[TMP2:%.*]] = xor i8 [[X:%.*]], -1 413; CHECK-NEXT: [[NOT:%.*]] = and i8 [[TMP1]], [[TMP2]] 414; CHECK-NEXT: ret i8 [[NOT]] 415; 416 %s = sub i8 0, %y 417 %o = or i8 %s, %x 418 %not = xor i8 %o, -1 419 ret i8 %not 420} 421 422define <3 x i5> @not_or_neg_commute_vec(<3 x i5> %x, <3 x i5> %p) { 423; CHECK-LABEL: @not_or_neg_commute_vec( 424; CHECK-NEXT: [[Y:%.*]] = mul <3 x i5> [[P:%.*]], <i5 1, i5 2, i5 3> 425; CHECK-NEXT: [[TMP1:%.*]] = add <3 x i5> [[X:%.*]], <i5 -1, i5 -1, i5 -1> 426; CHECK-NEXT: [[TMP2:%.*]] = xor <3 x i5> [[Y]], <i5 -1, i5 -1, i5 -1> 427; CHECK-NEXT: [[NOT:%.*]] = and <3 x i5> [[TMP1]], [[TMP2]] 428; CHECK-NEXT: ret <3 x i5> [[NOT]] 429; 430 %y = mul <3 x i5> %p, <i5 1, i5 2, i5 3> ; thwart complexity-based-canonicalization 431 %s = sub <3 x i5> <i5 0, i5 0, i5 undef>, %x 432 %o = or <3 x i5> %y, %s 433 %not = xor <3 x i5> %o, <i5 -1, i5 undef, i5 -1> 434 ret <3 x i5> %not 435} 436 437; negative test 438 439define i8 @not_or_neg_use1(i8 %x, i8 %y) { 440; CHECK-LABEL: @not_or_neg_use1( 441; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[Y:%.*]] 442; CHECK-NEXT: call void @use8(i8 [[S]]) 443; CHECK-NEXT: [[O:%.*]] = or i8 [[S]], [[X:%.*]] 444; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[O]], -1 445; CHECK-NEXT: ret i8 [[NOT]] 446; 447 %s = sub i8 0, %y 448 call void @use8(i8 %s) 449 %o = or i8 %s, %x 450 %not = xor i8 %o, -1 451 ret i8 %not 452} 453 454; negative test 455 456define i8 @not_or_neg_use2(i8 %x, i8 %y) { 457; CHECK-LABEL: @not_or_neg_use2( 458; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[Y:%.*]] 459; CHECK-NEXT: [[O:%.*]] = or i8 [[S]], [[X:%.*]] 460; CHECK-NEXT: call void @use8(i8 [[O]]) 461; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[O]], -1 462; CHECK-NEXT: ret i8 [[NOT]] 463; 464 %s = sub i8 0, %y 465 %o = or i8 %s, %x 466 call void @use8(i8 %o) 467 %not = xor i8 %o, -1 468 ret i8 %not 469} 470 471define i1 @not_select_bool(i1 %x, i1 %y, i1 %z) { 472; CHECK-LABEL: @not_select_bool( 473; CHECK-NEXT: [[SEL:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 [[Z:%.*]] 474; CHECK-NEXT: [[R:%.*]] = xor i1 [[SEL]], true 475; CHECK-NEXT: ret i1 [[R]] 476; 477 %sel = select i1 %x, i1 %y, i1 %z 478 %r = xor i1 %sel, true 479 ret i1 %r 480} 481 482define i1 @not_select_bool_const1(i1 %x, i1 %y) { 483; CHECK-LABEL: @not_select_bool_const1( 484; CHECK-NEXT: [[NOT_X:%.*]] = xor i1 [[X:%.*]], true 485; CHECK-NEXT: [[SEL:%.*]] = select i1 [[NOT_X]], i1 true, i1 [[Y:%.*]] 486; CHECK-NEXT: [[R:%.*]] = xor i1 [[SEL]], true 487; CHECK-NEXT: ret i1 [[R]] 488; 489 %sel = select i1 %x, i1 %y, i1 true 490 %r = xor i1 %sel, true 491 ret i1 %r 492} 493 494define i1 @not_select_bool_const2(i1 %x, i1 %y) { 495; CHECK-LABEL: @not_select_bool_const2( 496; CHECK-NEXT: [[SEL:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 false 497; CHECK-NEXT: [[R:%.*]] = xor i1 [[SEL]], true 498; CHECK-NEXT: ret i1 [[R]] 499; 500 %sel = select i1 %x, i1 %y, i1 false 501 %r = xor i1 %sel, true 502 ret i1 %r 503} 504 505define i1 @not_select_bool_const3(i1 %x, i1 %y) { 506; CHECK-LABEL: @not_select_bool_const3( 507; CHECK-NEXT: [[SEL:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[Y:%.*]] 508; CHECK-NEXT: [[R:%.*]] = xor i1 [[SEL]], true 509; CHECK-NEXT: ret i1 [[R]] 510; 511 %sel = select i1 %x, i1 true, i1 %y 512 %r = xor i1 %sel, true 513 ret i1 %r 514} 515 516define i1 @not_select_bool_const4(i1 %x, i1 %y) { 517; CHECK-LABEL: @not_select_bool_const4( 518; CHECK-NEXT: [[NOT_X:%.*]] = xor i1 [[X:%.*]], true 519; CHECK-NEXT: [[SEL:%.*]] = select i1 [[NOT_X]], i1 [[Y:%.*]], i1 false 520; CHECK-NEXT: [[R:%.*]] = xor i1 [[SEL]], true 521; CHECK-NEXT: ret i1 [[R]] 522; 523 %sel = select i1 %x, i1 false, i1 %y 524 %r = xor i1 %sel, true 525 ret i1 %r 526} 527