|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -passes=instcombine -S < %s | FileCheck %s |
| 3 | + |
| 4 | +define i8 @select_condition_implies_highbits_op1(i8 %xx, i8 %y) { |
| 5 | +; CHECK-LABEL: @select_condition_implies_highbits_op1( |
| 6 | +; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15 |
| 7 | +; CHECK-NEXT: [[COND:%.*]] = icmp ult i8 [[Y:%.*]], 3 |
| 8 | +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[Y]], i8 [[X]] |
| 9 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[SEL]], 32 |
| 10 | +; CHECK-NEXT: ret i8 [[R]] |
| 11 | +; |
| 12 | + %x = and i8 %xx, 15 |
| 13 | + %cond = icmp ult i8 %y, 3 |
| 14 | + %sel = select i1 %cond, i8 %y, i8 %x |
| 15 | + %r = add i8 %sel, 32 |
| 16 | + ret i8 %r |
| 17 | +} |
| 18 | + |
| 19 | +define i8 @select_condition_implies_highbits_op2(i8 %xx, i8 %y) { |
| 20 | +; CHECK-LABEL: @select_condition_implies_highbits_op2( |
| 21 | +; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15 |
| 22 | +; CHECK-NEXT: [[COND:%.*]] = icmp ugt i8 [[Y:%.*]], 3 |
| 23 | +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[Y]] |
| 24 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[SEL]], 32 |
| 25 | +; CHECK-NEXT: ret i8 [[R]] |
| 26 | +; |
| 27 | + %x = and i8 %xx, 15 |
| 28 | + %cond = icmp ugt i8 %y, 3 |
| 29 | + %sel = select i1 %cond, i8 %x, i8 %y |
| 30 | + %r = add i8 %sel, 32 |
| 31 | + ret i8 %r |
| 32 | +} |
| 33 | + |
| 34 | +define i8 @select_condition_implies_highbits_op1_and(i8 %xx, i8 %y, i1 %other_cond) { |
| 35 | +; CHECK-LABEL: @select_condition_implies_highbits_op1_and( |
| 36 | +; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15 |
| 37 | +; CHECK-NEXT: [[COND0:%.*]] = icmp ult i8 [[Y:%.*]], 3 |
| 38 | +; CHECK-NEXT: [[COND:%.*]] = and i1 [[COND0]], [[OTHER_COND:%.*]] |
| 39 | +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[Y]], i8 [[X]] |
| 40 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[SEL]], 32 |
| 41 | +; CHECK-NEXT: ret i8 [[R]] |
| 42 | +; |
| 43 | + %x = and i8 %xx, 15 |
| 44 | + %cond0 = icmp ult i8 %y, 3 |
| 45 | + %cond = and i1 %cond0, %other_cond |
| 46 | + %sel = select i1 %cond, i8 %y, i8 %x |
| 47 | + %r = add i8 %sel, 32 |
| 48 | + ret i8 %r |
| 49 | +} |
| 50 | + |
| 51 | +define i8 @select_condition_implies_highbits_op2_or(i8 %xx, i8 %y, i1 %other_cond) { |
| 52 | +; CHECK-LABEL: @select_condition_implies_highbits_op2_or( |
| 53 | +; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15 |
| 54 | +; CHECK-NEXT: [[COND0:%.*]] = icmp ugt i8 [[Y:%.*]], 3 |
| 55 | +; CHECK-NEXT: [[COND:%.*]] = or i1 [[COND0]], [[OTHER_COND:%.*]] |
| 56 | +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[Y]] |
| 57 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[SEL]], 32 |
| 58 | +; CHECK-NEXT: ret i8 [[R]] |
| 59 | +; |
| 60 | + %x = and i8 %xx, 15 |
| 61 | + %cond0 = icmp ugt i8 %y, 3 |
| 62 | + %cond = or i1 %cond0, %other_cond |
| 63 | + %sel = select i1 %cond, i8 %x, i8 %y |
| 64 | + %r = add i8 %sel, 32 |
| 65 | + ret i8 %r |
| 66 | +} |
0 commit comments