1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
4 define i8 @select_condition_implies_highbits_op1(i8 %xx, i8 noundef %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:%.*]] = or disjoint i8 [[SEL]], 32
10 ; CHECK-NEXT: ret i8 [[R]]
13 %cond = icmp ult i8 %y, 3
14 %sel = select i1 %cond, i8 %y, i8 %x
19 define i8 @select_condition_implies_highbits_op1_maybe_undef_fail(i8 %xx, i8 %y) {
20 ; CHECK-LABEL: @select_condition_implies_highbits_op1_maybe_undef_fail(
21 ; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15
22 ; CHECK-NEXT: [[COND:%.*]] = icmp ult i8 [[Y:%.*]], 3
23 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[Y]], i8 [[X]]
24 ; CHECK-NEXT: [[R:%.*]] = add i8 [[SEL]], 32
25 ; CHECK-NEXT: ret i8 [[R]]
28 %cond = icmp ult i8 %y, 3
29 %sel = select i1 %cond, i8 %y, i8 %x
34 define i8 @select_condition_implies_highbits_op2(i8 %xx, i8 noundef %y) {
35 ; CHECK-LABEL: @select_condition_implies_highbits_op2(
36 ; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15
37 ; CHECK-NEXT: [[COND:%.*]] = icmp ugt i8 [[Y:%.*]], 3
38 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[Y]]
39 ; CHECK-NEXT: [[R:%.*]] = or disjoint i8 [[SEL]], 32
40 ; CHECK-NEXT: ret i8 [[R]]
43 %cond = icmp ugt i8 %y, 3
44 %sel = select i1 %cond, i8 %x, i8 %y
49 define i8 @select_condition_implies_highbits_op1_and(i8 %xx, i8 noundef %y, i1 %other_cond) {
50 ; CHECK-LABEL: @select_condition_implies_highbits_op1_and(
51 ; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15
52 ; CHECK-NEXT: [[COND0:%.*]] = icmp ult i8 [[Y:%.*]], 3
53 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[COND0]], [[OTHER_COND:%.*]]
54 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[Y]], i8 [[X]]
55 ; CHECK-NEXT: [[R:%.*]] = or disjoint i8 [[SEL]], 32
56 ; CHECK-NEXT: ret i8 [[R]]
59 %cond0 = icmp ult i8 %y, 3
60 %cond = and i1 %cond0, %other_cond
61 %sel = select i1 %cond, i8 %y, i8 %x
66 define i8 @select_condition_implies_highbits_op2_or(i8 %xx, i8 noundef %y, i1 %other_cond) {
67 ; CHECK-LABEL: @select_condition_implies_highbits_op2_or(
68 ; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 15
69 ; CHECK-NEXT: [[COND0:%.*]] = icmp ugt i8 [[Y:%.*]], 3
70 ; CHECK-NEXT: [[COND:%.*]] = or i1 [[COND0]], [[OTHER_COND:%.*]]
71 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X]], i8 [[Y]]
72 ; CHECK-NEXT: [[R:%.*]] = or disjoint i8 [[SEL]], 32
73 ; CHECK-NEXT: ret i8 [[R]]
76 %cond0 = icmp ugt i8 %y, 3
77 %cond = or i1 %cond0, %other_cond
78 %sel = select i1 %cond, i8 %x, i8 %y