brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 92b3a81 Raw
63 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare void @llvm.assume(i1)5declare i8 @llvm.ctpop.i8(i8)6 7; https://alive2.llvm.org/ce/z/LV_8xy8define i8 @and_add_shl(i8 %x) {9; CHECK-LABEL: define i8 @and_add_shl10; CHECK-SAME: (i8 [[X:%.*]]) {11; CHECK-NEXT:    [[OP1_P2:%.*]] = icmp ult i8 [[X]], 612; CHECK-NEXT:    call void @llvm.assume(i1 [[OP1_P2]])13; CHECK-NEXT:    [[NOTMASK:%.*]] = shl nsw i8 -1, [[X]]14; CHECK-NEXT:    [[SUB:%.*]] = and i8 [[NOTMASK]], 3215; CHECK-NEXT:    [[R:%.*]] = xor i8 [[SUB]], 3216; CHECK-NEXT:    ret i8 [[R]]17;18  %op1_p2 = icmp ule i8 %x, 519  call void @llvm.assume(i1 %op1_p2)20  %shift = shl i8 1, %x21  %sub = add i8 %shift, -122  %r = and i8 %sub, 3223  ret i8 %r24}25 26; https://alive2.llvm.org/ce/z/YNYYdV27define i8 @and_not_shl(i8 %x) {28; CHECK-LABEL: define i8 @and_not_shl29; CHECK-SAME: (i8 [[X:%.*]]) {30; CHECK-NEXT:    [[OP1_P2:%.*]] = icmp ult i8 [[X]], 631; CHECK-NEXT:    call void @llvm.assume(i1 [[OP1_P2]])32; CHECK-NEXT:    [[SHIFT:%.*]] = shl nsw i8 -1, [[X]]33; CHECK-NEXT:    [[NOT:%.*]] = and i8 [[SHIFT]], 3234; CHECK-NEXT:    [[R:%.*]] = xor i8 [[NOT]], 3235; CHECK-NEXT:    ret i8 [[R]]36;37  %op1_p2 = icmp ule i8 %x, 538  call void @llvm.assume(i1 %op1_p2)39  %shift = shl i8 -1, %x40  %not = xor i8 %shift, -141  %r = and i8 %not, 3242  ret i8 %r43}44 45; Negative test: https://alive2.llvm.org/ce/z/uWzb4t46define i8 @and_add_shl_overlap(i8 %x) {47; CHECK-LABEL: define i8 @and_add_shl_overlap48; CHECK-SAME: (i8 [[X:%.*]]) {49; CHECK-NEXT:    [[OP1_P2:%.*]] = icmp ult i8 [[X]], 750; CHECK-NEXT:    call void @llvm.assume(i1 [[OP1_P2]])51; CHECK-NEXT:    [[NOTMASK:%.*]] = shl nsw i8 -1, [[X]]52; CHECK-NEXT:    [[SUB:%.*]] = and i8 [[NOTMASK]], 3253; CHECK-NEXT:    [[R:%.*]] = xor i8 [[SUB]], 3254; CHECK-NEXT:    ret i8 [[R]]55;56  %op1_p2 = icmp ule i8 %x, 657  call void @llvm.assume(i1 %op1_p2)58  %shift = shl i8 1, %x59  %sub = add i8 %shift, -160  %r = and i8 %sub, 3261  ret i8 %r62}63