llvm.org GIT mirror llvm / e18ca39
[EarlyCSE] add test for select condition double-negation; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358444 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 5 months ago
1 changed file(s) with 21 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
450450 %r = xor i32 %m2, %m1
451451 ret i32 %r
452452 }
453
454 ; TODO: If we have both an inverted predicate and a 'not' op, recognize the double-negation.
455
456 define i32 @select_not_invert_pred_cond(i8 %x, i32 %t, i32 %f) {
457 ; CHECK-LABEL: @select_not_invert_pred_cond(
458 ; CHECK-NEXT: [[COND:%.*]] = icmp ugt i8 [[X:%.*]], 42
459 ; CHECK-NEXT: [[INVCOND:%.*]] = icmp ule i8 [[X]], 42
460 ; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[INVCOND]], true
461 ; CHECK-NEXT: [[M1:%.*]] = select i1 [[COND]], i32 [[T:%.*]], i32 [[F:%.*]]
462 ; CHECK-NEXT: [[M2:%.*]] = select i1 [[NOT]], i32 [[T]], i32 [[F]]
463 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[M1]], [[M2]]
464 ; CHECK-NEXT: ret i32 [[R]]
465 ;
466 %cond = icmp ugt i8 %x, 42
467 %invcond = icmp ule i8 %x, 42
468 %not = xor i1 %invcond, -1
469 %m1 = select i1 %cond, i32 %t, i32 %f
470 %m2 = select i1 %not, i32 %t, i32 %f
471 %r = xor i32 %m1, %m2
472 ret i32 %r
473 }