brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 66a7eb7 Raw
146 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -S -passes=instcombine | FileCheck %s3 4declare void @use(i1)5 6define i1 @a_or_b(i32 %a, i32 %b)  {7; CHECK-LABEL: define i1 @a_or_b(8; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {9; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[A]], 010; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i32 [[B]], 011; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[TMP1]], [[TMP2]]12; CHECK-NEXT:    ret i1 [[OR]]13;14  %a_eq_zero = icmp eq i32 %a, 015  %b_ne_zero = icmp ne i32 %b, 016  %and.1 = and i1 %a_eq_zero, %b_ne_zero17  %a_ne_zero = icmp ne i32 %a, 018  %b_eq_zero = icmp eq i32 %b, 019  %and.2 = and i1 %a_ne_zero, %b_eq_zero20  %or = or i1 %and.1, %and.221  ret i1 %or22}23 24define i1 @a_or_b_not_inv(i32 %a, i32 %b){25; CHECK-LABEL: define i1 @a_or_b_not_inv(26; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {27; CHECK-NEXT:    [[A_EQ_ZERO:%.*]] = icmp eq i32 [[A]], 028; CHECK-NEXT:    [[B_NE_ZERO:%.*]] = icmp ne i32 [[B]], 029; CHECK-NEXT:    [[AND_1:%.*]] = and i1 [[A_EQ_ZERO]], [[B_NE_ZERO]]30; CHECK-NEXT:    [[A_NE_ZERO:%.*]] = icmp ne i32 [[A]], 031; CHECK-NEXT:    [[B_EQ_1:%.*]] = icmp eq i32 [[B]], 132; CHECK-NEXT:    [[AND_2:%.*]] = and i1 [[A_NE_ZERO]], [[B_EQ_1]]33; CHECK-NEXT:    [[OR:%.*]] = or i1 [[AND_1]], [[AND_2]]34; CHECK-NEXT:    ret i1 [[OR]]35;36  %a_eq_zero = icmp eq i32 %a, 037  %b_ne_zero = icmp ne i32 %b, 038  %and.1 = and i1 %a_eq_zero, %b_ne_zero39  %a_ne_zero = icmp ne i32 %a, 040  %b_eq_1 = icmp eq i32 %b, 141  %and.2 = and i1 %a_ne_zero, %b_eq_142  %or = or i1 %and.1, %and.243  ret i1 %or44}45 46define i1 @a_or_b_const(i32 %a, i32 %b, i32 %c)  {47; CHECK-LABEL: define i1 @a_or_b_const(48; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]]) {49; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[A]], [[C]]50; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i32 [[B]], [[C]]51; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[TMP1]], [[TMP2]]52; CHECK-NEXT:    ret i1 [[OR]]53;54  %a_eq_c = icmp eq i32 %a, %c55  %b_ne_c = icmp ne i32 %b, %c56  %and.1 = and i1 %a_eq_c, %b_ne_c57  %a_ne_c = icmp ne i32 %a, %c58  %b_eq_c = icmp eq i32 %b, %c59  %and.2 = and i1 %a_ne_c, %b_eq_c60  %or = or i1 %and.1, %and.261  ret i1 %or62}63 64define i1 @a_or_b_const2(i32 %a, i32 %b, i32 %c, i32 %d)  {65; CHECK-LABEL: define i1 @a_or_b_const2(66; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]], i32 [[D:%.*]]) {67; CHECK-NEXT:    [[A_EQ_C:%.*]] = icmp eq i32 [[A]], [[C]]68; CHECK-NEXT:    [[B_EQ_D:%.*]] = icmp eq i32 [[B]], [[D]]69; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[A_EQ_C]], [[B_EQ_D]]70; CHECK-NEXT:    ret i1 [[OR]]71;72  %a_eq_c = icmp eq i32 %a, %c73  %b_ne_d = icmp ne i32 %b, %d74  %and.1 = and i1 %a_eq_c, %b_ne_d75  %a_ne_c = icmp ne i32 %a, %c76  %b_eq_d = icmp eq i32 %b, %d77  %and.2 = and i1 %a_ne_c, %b_eq_d78  %or = or i1 %and.1, %and.279  ret i1 %or80}81define i1 @a_or_b_nullptr(ptr %a, ptr %b) {82; CHECK-LABEL: define i1 @a_or_b_nullptr(83; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]]) {84; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq ptr [[A]], null85; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq ptr [[B]], null86; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[TMP1]], [[TMP2]]87; CHECK-NEXT:    ret i1 [[OR]]88;89  %a_null = icmp eq ptr %a, null90  %b_null = icmp eq ptr %b, null91  %a_not_null = icmp ne ptr %a, null92  %b_not_null = icmp ne ptr %b, null93  %and.1 = and i1 %a_null, %b_not_null94  %and.2 = and i1 %a_not_null, %b_null95  %or = or i1 %and.1, %and.296  ret i1 %or97}98 99define i1 @a_or_b_multiple_uses(i32 %a, i32 %b)  {100; CHECK-LABEL: define i1 @a_or_b_multiple_uses(101; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {102; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[A]], 0103; CHECK-NEXT:    [[A_NE_ZERO:%.*]] = icmp ne i32 [[A]], 0104; CHECK-NEXT:    [[B_EQ_ZERO:%.*]] = icmp eq i32 [[B]], 0105; CHECK-NEXT:    [[AND_2:%.*]] = and i1 [[A_NE_ZERO]], [[B_EQ_ZERO]]106; CHECK-NEXT:    call void @use(i1 [[AND_2]])107; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[TMP1]], [[B_EQ_ZERO]]108; CHECK-NEXT:    ret i1 [[OR]]109;110  %a_eq_zero = icmp eq i32 %a, 0111  %b_ne_zero = icmp ne i32 %b, 0112  %and.1 = and i1 %a_eq_zero, %b_ne_zero113  %a_ne_zero = icmp ne i32 %a, 0114  %b_eq_zero = icmp eq i32 %b, 0115  %and.2 = and i1 %a_ne_zero, %b_eq_zero116  call void @use(i1 %and.2)117  %or = or i1 %and.1, %and.2118  ret i1 %or119}120 121define i1 @a_or_b_multiple_uses_2(i32 %a, i32 %b)  {122; CHECK-LABEL: define i1 @a_or_b_multiple_uses_2(123; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {124; CHECK-NEXT:    [[A_EQ_ZERO:%.*]] = icmp eq i32 [[A]], 0125; CHECK-NEXT:    [[B_NE_ZERO:%.*]] = icmp ne i32 [[B]], 0126; CHECK-NEXT:    call void @use(i1 [[B_NE_ZERO]])127; CHECK-NEXT:    [[AND_1:%.*]] = and i1 [[A_EQ_ZERO]], [[B_NE_ZERO]]128; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[B]], 0129; CHECK-NEXT:    call void @use(i1 [[AND_1]])130; CHECK-NEXT:    [[OR:%.*]] = xor i1 [[A_EQ_ZERO]], [[TMP1]]131; CHECK-NEXT:    ret i1 [[OR]]132;133  %a_eq_zero = icmp eq i32 %a, 0134  %b_ne_zero = icmp ne i32 %b, 0135  call void @use(i1 %b_ne_zero)136  %and.1 = and i1 %a_eq_zero, %b_ne_zero137  %a_ne_zero = icmp ne i32 %a, 0138  %b_eq_zero = icmp eq i32 %b, 0139  %and.2 = and i1 %a_ne_zero, %b_eq_zero140  call void @use(i1 %and.1)141  %or = or i1 %and.1, %and.2142  ret i1 %or143}144 145 146