199 lines · plain
1; RUN: opt -S -disable-output -passes="print<demanded-bits>" < %s 2>&1 | FileCheck %s2 3define i8 @test_ashr_const_amount_4(i32 %a) {4; CHECK-LABEL: 'test_ashr_const_amount_4'5; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, 46; CHECK-DAG: DemandedBits: 0xff0 for %a in %ashr = ashr i32 %a, 47; CHECK-DAG: DemandedBits: 0xffffffff for 4 in %ashr = ashr i32 %a, 48; CHECK-DAG: DemandedBits: 0xff for %ashr.t = trunc i32 %ashr to i89; CHECK-DAG: DemandedBits: 0xff for %ashr in %ashr.t = trunc i32 %ashr to i810;11 %ashr = ashr i32 %a, 412 %ashr.t = trunc i32 %ashr to i813 ret i8 %ashr.t14}15 16define i8 @test_ashr_const_amount_5(i32 %a) {17; CHECK-LABEL: 'test_ashr_const_amount_5'18; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, 519; CHECK-DAG: DemandedBits: 0x1fe0 for %a in %ashr = ashr i32 %a, 520; CHECK-DAG: DemandedBits: 0xffffffff for 5 in %ashr = ashr i32 %a, 521; CHECK-DAG: DemandedBits: 0xff for %ashr.t = trunc i32 %ashr to i822; CHECK-DAG: DemandedBits: 0xff for %ashr in %ashr.t = trunc i32 %ashr to i823;24 %ashr = ashr i32 %a, 525 %ashr.t = trunc i32 %ashr to i826 ret i8 %ashr.t27}28 29define i8 @test_ashr_const_amount_8(i32 %a) {30; CHECK-LABEL: 'test_ashr_const_amount_8'31; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, 832; CHECK-DAG: DemandedBits: 0xff00 for %a in %ashr = ashr i32 %a, 833; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %ashr = ashr i32 %a, 834; CHECK-DAG: DemandedBits: 0xff for %ashr.t = trunc i32 %ashr to i835; CHECK-DAG: DemandedBits: 0xff for %ashr in %ashr.t = trunc i32 %ashr to i836;37 %ashr = ashr i32 %a, 838 %ashr.t = trunc i32 %ashr to i839 ret i8 %ashr.t40}41 42define i8 @test_ashr_const_amount_9(i32 %a) {43 44; CHECK-LABEL: 'test_ashr_const_amount_9'45; CHECK-DAG: DemandedBits: 0xff for %ashr.t = trunc i32 %ashr to i846; CHECK-DAG: DemandedBits: 0xff for %ashr in %ashr.t = trunc i32 %ashr to i847; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, 848; CHECK-DAG: DemandedBits: 0xff00 for %a in %ashr = ashr i32 %a, 849; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %ashr = ashr i32 %a, 850;51 %ashr = ashr i32 %a, 852 %ashr.t = trunc i32 %ashr to i853 ret i8 %ashr.t54}55 56define i8 @test_ashr(i32 %a, i32 %b) {57; CHECK-LABEL: 'test_ashr'58; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, %b59; CHECK-DAG: DemandedBits: 0xffffffff for %a in %ashr = ashr i32 %a, %b60; CHECK-DAG: DemandedBits: 0xffffffff for %b in %ashr = ashr i32 %a, %b61; CHECK-DAG: DemandedBits: 0xff for %ashr.t = trunc i32 %ashr to i862; CHECK-DAG: DemandedBits: 0xff for %ashr in %ashr.t = trunc i32 %ashr to i863;64 %ashr = ashr i32 %a, %b65 %ashr.t = trunc i32 %ashr to i866 ret i8 %ashr.t67}68 69define i8 @test_ashr_range_1(i32 %a, i32 %b) {70; CHECK-LABEL: 'test_ashr_range_1'71; CHECK-DAG: DemandedBits: 0xff for %shl.t = trunc i32 %ashr to i872; CHECK-DAG: DemandedBits: 0xff for %ashr in %shl.t = trunc i32 %ashr to i873; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 374; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 375; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 376; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, %b277; CHECK-DAG: DemandedBits: 0x7ff for %a in %ashr = ashr i32 %a, %b278; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %ashr = ashr i32 %a, %b279;80 %b2 = and i32 %b, 381 %ashr = ashr i32 %a, %b282 %shl.t = trunc i32 %ashr to i883 ret i8 %shl.t84}85 86define i32 @test_ashr_range_2(i32 %a, i32 %b) {87; CHECK-LABEL: 'test_ashr_range_2'88; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 389; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 390; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 391; CHECK-DAG: DemandedBits: 0xffffffff for %ashr = ashr i32 %a, %b292; CHECK-DAG: DemandedBits: 0xffffffff for %a in %ashr = ashr i32 %a, %b293; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %ashr = ashr i32 %a, %b294;95 %b2 = and i32 %b, 396 %ashr = ashr i32 %a, %b297 ret i32 %ashr98}99 100define i32 @test_ashr_range_3(i32 %a, i32 %b) {101; CHECK-LABEL: 'test_ashr_range_3'102; CHECK-DAG: DemandedBits: 0xffff for %ashr = ashr i32 %a, %b103; CHECK-DAG: DemandedBits: 0xffffffff for %a in %ashr = ashr i32 %a, %b104; CHECK-DAG: DemandedBits: 0xffffffff for %b in %ashr = ashr i32 %a, %b105; CHECK-DAG: DemandedBits: 0xffffffff for %shl = shl i32 %ashr, 16106; CHECK-DAG: DemandedBits: 0xffff for %ashr in %shl = shl i32 %ashr, 16107; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %shl = shl i32 %ashr, 16108;109 %ashr = ashr i32 %a, %b110 %shl = shl i32 %ashr, 16111 ret i32 %shl112}113define i32 @test_ashr_range_4(i32 %a, i32 %b) {114; CHECK-LABEL: 'test_ashr_range_4'115; CHECK-DAG: DemandedBits: 0xffffffff for %shr = lshr i32 %ashr, 8116; CHECK-DAG: DemandedBits: 0xffffff00 for %ashr in %shr = lshr i32 %ashr, 8117; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %shr = lshr i32 %ashr, 8118; CHECK-DAG: DemandedBits: 0xffffff00 for %ashr = ashr i32 %a, %b119; CHECK-DAG: DemandedBits: 0xffffff00 for %a in %ashr = ashr i32 %a, %b120; CHECK-DAG: DemandedBits: 0xffffffff for %b in %ashr = ashr i32 %a, %b121 %ashr = ashr i32 %a, %b122 %shr = lshr i32 %ashr, 8123 ret i32 %shr124}125 126define i32 @test_ashr_range_5(i32 %a, i32 %b) {127; CHECK-LABEL: 'test_ashr_range_5'128; CHECK-DAG: DemandedBits: 0xffffffff for %2 = and i32 %1, 255129; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = and i32 %1, 255130; CHECK-DAG: DemandedBits: 0xffffffff for 255 in %2 = and i32 %1, 255131; CHECK-DAG: DemandedBits: 0xff for %1 = ashr i32 %a, %b132; CHECK-DAG: DemandedBits: 0xffffffff for %a in %1 = ashr i32 %a, %b133; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = ashr i32 %a, %b134;135 %1 = ashr i32 %a, %b136 %2 = and i32 %1, 255137 ret i32 %2138}139 140define i32 @test_ashr_range_6(i32 %a, i32 %b) {141; CHECK-LABEL: 'test_ashr_range_6'142; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 = ashr i32 %a, %b143; CHECK-DAG: DemandedBits: 0xffff0000 for %a in %lshr.1 = ashr i32 %a, %b144; CHECK-DAG: DemandedBits: 0xffffffff for %b in %lshr.1 = ashr i32 %a, %b145; CHECK-DAG: DemandedBits: 0xffffffff for %lshr.2 = ashr i32 %lshr.1, 16146; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 in %lshr.2 = ashr i32 %lshr.1, 16147; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %lshr.2 = ashr i32 %lshr.1, 16148;149 %lshr.1 = ashr i32 %a, %b150 %lshr.2 = ashr i32 %lshr.1, 16151 ret i32 %lshr.2152}153 154define i8 @test_ashr_var_amount(i32 %a, i32 %b){155; CHECK-LABEL: 'test_ashr_var_amount'156; CHECK-DAG: DemandedBits: 0xff for %4 = ashr i32 %1, %3157; CHECK-DAG: DemandedBits: 0xffffffff for %1 in %4 = ashr i32 %1, %3158; CHECK-DAG: DemandedBits: 0xffffffff for %3 in %4 = ashr i32 %1, %3159; CHECK-DAG: DemandedBits: 0xff for %2 = trunc i32 %1 to i8160; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = trunc i32 %1 to i8161; CHECK-DAG: DemandedBits: 0xffffffff for %1 = add nsw i32 %a, %b162; CHECK-DAG: DemandedBits: 0xffffffff for %a in %1 = add nsw i32 %a, %b163; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = add nsw i32 %a, %b164; CHECK-DAG: DemandedBits: 0xffffffff for %3 = zext i8 %2 to i32165; CHECK-DAG: DemandedBits: 0xff for %2 in %3 = zext i8 %2 to i32166; CHECK-DAG: DemandedBits: 0xff for %5 = trunc i32 %4 to i8167; CHECK-DAG: DemandedBits: 0xff for %4 in %5 = trunc i32 %4 to i8168;169 %1 = add nsw i32 %a, %b170 %2 = trunc i32 %1 to i8171 %3 = zext i8 %2 to i32172 %4 = ashr i32 %1, %3173 %5 = trunc i32 %4 to i8174 ret i8 %5175}176 177define i8 @test_ashr_var_amount_nsw(i32 %a, i32 %b){178 ; CHECK-LABEL 'test_ashr_var_amount_nsw'179 ; CHECK-DAG: DemandedBits: 0xff for %5 = trunc i32 %4 to i8180 ; CHECK-DAG: DemandedBits: 0xff for %4 in %5 = trunc i32 %4 to i8181 ; CHECK-DAG: DemandedBits: 0xffffffff for %1 = add nsw i32 %a, %b182 ; CHECK-DAG: DemandedBits: 0xffffffff for %a in %1 = add nsw i32 %a, %b183 ; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = add nsw i32 %a, %b184 ; CHECK-DAG: DemandedBits: 0xff for %2 = trunc i32 %1 to i8185 ; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = trunc i32 %1 to i8186 ; CHECK-DAG: DemandedBits: 0xffffffff for %3 = zext i8 %2 to i32187 ; CHECK-DAG: DemandedBits: 0xff for %2 in %3 = zext i8 %2 to i32188 ; CHECK-DAG: DemandedBits: 0xff for %4 = ashr exact i32 %1, %3189 ; CHECK-DAG: DemandedBits: 0xffffffff for %1 in %4 = ashr exact i32 %1, %3190 ; CHECK-DAG: DemandedBits: 0xffffffff for %3 in %4 = ashr exact i32 %1, %3191 ;192 %1 = add nsw i32 %a, %b193 %2 = trunc i32 %1 to i8194 %3 = zext i8 %2 to i32195 %4 = ashr exact i32 %1, %3196 %5 = trunc i32 %4 to i8197 ret i8 %5198}199