brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · f9618e1 Raw
169 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=instsimplify -S < %s | FileCheck %s3 4declare i8 @llvm.sadd.sat.i8(i8, i8)5declare i8 @llvm.ssub.sat.i8(i8, i8)6declare i8 @llvm.uadd.sat.i8(i8, i8)7declare i8 @llvm.usub.sat.i8(i8, i8)8 9define i1 @uadd_sat_overflow(i8 %x, i8 %y) {10; CHECK-LABEL: @uadd_sat_overflow(11; CHECK-NEXT:    ret i1 false12;13  %lhs = or i8 %x, 12814  %rhs = or i8 %y, 12815  %exp = call i8 @llvm.uadd.sat.i8(i8 %lhs, i8 %rhs)16  %r = icmp eq i8 %exp, 25417  ret i1 %r18}19 20define i1 @uadd_sat_overflow_fail(i8 %x, i8 %y) {21; CHECK-LABEL: @uadd_sat_overflow_fail(22; CHECK-NEXT:    [[LHS:%.*]] = or i8 [[X:%.*]], -12823; CHECK-NEXT:    [[RHS:%.*]] = or i8 [[Y:%.*]], 12624; CHECK-NEXT:    [[EXP:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[LHS]], i8 [[RHS]])25; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[EXP]], -226; CHECK-NEXT:    ret i1 [[R]]27;28  %lhs = or i8 %x, 12829  %rhs = or i8 %y, 12630  %exp = call i8 @llvm.uadd.sat.i8(i8 %lhs, i8 %rhs)31  %r = icmp eq i8 %exp, 25432  ret i1 %r33}34 35define i1 @usub_sat_overflow(i8 %x, i8 %y) {36; CHECK-LABEL: @usub_sat_overflow(37; CHECK-NEXT:    ret i1 false38;39  %lhs = and i8 %x, 12740  %rhs = or i8 %y, 12841  %exp = call i8 @llvm.usub.sat.i8(i8 %lhs, i8 %rhs)42  %r = icmp eq i8 %exp, 143  ret i1 %r44}45 46define i1 @usub_sat_overflow_fail(i8 %x, i8 %y) {47; CHECK-LABEL: @usub_sat_overflow_fail(48; CHECK-NEXT:    [[LHS:%.*]] = and i8 [[X:%.*]], 12749; CHECK-NEXT:    [[RHS:%.*]] = or i8 [[Y:%.*]], 12650; CHECK-NEXT:    [[EXP:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[LHS]], i8 [[RHS]])51; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[EXP]], 152; CHECK-NEXT:    ret i1 [[R]]53;54  %lhs = and i8 %x, 12755  %rhs = or i8 %y, 12656  %exp = call i8 @llvm.usub.sat.i8(i8 %lhs, i8 %rhs)57  %r = icmp eq i8 %exp, 158  ret i1 %r59}60 61define i1 @sadd_sat_overflow_pos(i8 %x, i8 %y) {62; CHECK-LABEL: @sadd_sat_overflow_pos(63; CHECK-NEXT:    ret i1 false64;65  %xx = and i8 %x, 12766  %yy = and i8 %y, 12767  %lhs = or i8 %xx, 6468  %rhs = or i8 %yy, 6569  %exp = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)70  %r = icmp eq i8 %exp, 12871  ret i1 %r72}73 74define i1 @sadd_sat_low_bits(i8 %x, i8 %y) {75; CHECK-LABEL: @sadd_sat_low_bits(76; CHECK-NEXT:    ret i1 false77;78  %xx = and i8 %x, 1579  %yy = and i8 %y, 1580  %lhs = or i8 %xx, 181  %rhs = and i8 %yy, -282  %exp = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)83  %and = and i8 %exp, 184  %r = icmp eq i8 %and, 085  ret i1 %r86}87 88define i1 @sadd_sat_fail_may_overflow(i8 %x, i8 %y) {89; CHECK-LABEL: @sadd_sat_fail_may_overflow(90; CHECK-NEXT:    [[LHS:%.*]] = or i8 [[X:%.*]], 191; CHECK-NEXT:    [[RHS:%.*]] = and i8 [[Y:%.*]], -292; CHECK-NEXT:    [[EXP:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[LHS]], i8 [[RHS]])93; CHECK-NEXT:    [[AND:%.*]] = and i8 [[EXP]], 194; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[AND]], 095; CHECK-NEXT:    ret i1 [[R]]96;97  %lhs = or i8 %x, 198  %rhs = and i8 %y, -299  %exp = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)100  %and = and i8 %exp, 1101  %r = icmp eq i8 %and, 0102  ret i1 %r103}104 105define i1 @sadd_sat_overflow_neg(i8 %x, i8 %y) {106; CHECK-LABEL: @sadd_sat_overflow_neg(107; CHECK-NEXT:    ret i1 false108;109  %lhs = or i8 %x, 192110  %rhs = or i8 %y, 191111  %exp = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)112  %r = icmp eq i8 %exp, 127113  ret i1 %r114}115 116define i1 @ssub_sat_overflow_neg(i8 %x, i8 %y) {117; CHECK-LABEL: @ssub_sat_overflow_neg(118; CHECK-NEXT:    ret i1 false119;120  %xx = and i8 %x, 112121  %yy = and i8 %y, 127122  %lhs = or i8 %xx, 128123  %rhs = or i8 %yy, 126124  %exp = call i8 @llvm.ssub.sat.i8(i8 %lhs, i8 %rhs)125  %r = icmp eq i8 %exp, 32126  ret i1 %r127}128 129define i1 @ssub_sat_low_bits(i8 %x, i8 %y) {130; CHECK-LABEL: @ssub_sat_low_bits(131; CHECK-NEXT:    ret i1 false132;133  %xx = and i8 %x, 15134  %yy = and i8 %y, 15135  %lhs = or i8 %xx, 17136  %rhs = and i8 %yy, -2137  %exp = call i8 @llvm.ssub.sat.i8(i8 %lhs, i8 %rhs)138  %and = and i8 %exp, 1139  %r = icmp eq i8 %and, 0140  ret i1 %r141}142 143define i1 @ssub_sat_fail_may_overflow(i8 %x, i8 %y) {144; CHECK-LABEL: @ssub_sat_fail_may_overflow(145; CHECK-NEXT:    ret i1 false146;147  %xx = and i8 %x, 15148  %yy = and i8 %y, 15149  %lhs = or i8 %xx, 1150  %rhs = and i8 %yy, -2151  %exp = call i8 @llvm.ssub.sat.i8(i8 %lhs, i8 %rhs)152  %and = and i8 %exp, 1153  %r = icmp eq i8 %and, 0154  ret i1 %r155}156 157define i1 @ssub_sat_overflow_pos(i8 %x, i8 %y) {158; CHECK-LABEL: @ssub_sat_overflow_pos(159; CHECK-NEXT:    ret i1 false160;161  %xx = and i8 %x, 24162  %yy = and i8 %y, 3163  %lhs = or i8 %xx, 8164  %rhs = or i8 %yy, 128165  %exp = call i8 @llvm.ssub.sat.i8(i8 %lhs, i8 %rhs)166  %r = icmp eq i8 %exp, 128167  ret i1 %r168}169