brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.8 KiB · 16e84a6 Raw
299 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-combiner --aarch64postlegalizercombiner-only-enable-rule="bitfield_extract_from_and" -verify-machineinstrs %s -o - | FileCheck %s3# REQUIRES: asserts4 5# Check that we can combine6#7# and (lshr x, cst), mask -> ubfx x, cst, width8 9# LSB = 510# Width = LSB + trailing_ones(255) - 1 =11#         5 + 8 - 1 = 1212 13...14---15name:            ubfx_s3216tracksRegLiveness: true17legalized: true18body:             |19  bb.0:20    liveins: $w021 22 23    ; CHECK-LABEL: name: ubfx_s3224    ; CHECK: liveins: $w025    ; CHECK-NEXT: {{  $}}26    ; CHECK-NEXT: %x:_(s32) = COPY $w027    ; CHECK-NEXT: %lsb:_(s32) = G_CONSTANT i32 528    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 829    ; CHECK-NEXT: %and:_(s32) = G_UBFX %x, %lsb(s32), [[C]]30    ; CHECK-NEXT: $w0 = COPY %and(s32)31    ; CHECK-NEXT: RET_ReallyLR implicit $w032    %x:_(s32) = COPY $w033    %lsb:_(s32) = G_CONSTANT i32 534    %mask:_(s32) = G_CONSTANT i32 25535    %shift:_(s32) = G_LSHR %x, %lsb36    %and:_(s32) = G_AND %shift, %mask37    $w0 = COPY %and38    RET_ReallyLR implicit $w039 40# LSB = 541# Width = LSB + trailing_ones(1) - 1 =42#          5 + 1 - 1 = 543 44...45---46name:            ubfx_s6447tracksRegLiveness: true48legalized: true49body:             |50  bb.0:51    liveins: $x052 53    ; CHECK-LABEL: name: ubfx_s6454    ; CHECK: liveins: $x055    ; CHECK-NEXT: {{  $}}56    ; CHECK-NEXT: %x:_(s64) = COPY $x057    ; CHECK-NEXT: %lsb:_(s64) = G_CONSTANT i64 558    ; CHECK-NEXT: %mask:_(s64) = G_CONSTANT i64 159    ; CHECK-NEXT: %and:_(s64) = G_UBFX %x, %lsb(s64), %mask60    ; CHECK-NEXT: $x0 = COPY %and(s64)61    ; CHECK-NEXT: RET_ReallyLR implicit $x062    %x:_(s64) = COPY $x063    %lsb:_(s64) = G_CONSTANT i64 564    %mask:_(s64) = G_CONSTANT i64 165    %shift:_(s64) = G_LSHR %x, %lsb66    %and:_(s64) = G_AND %shift, %mask67    $x0 = COPY %and68    RET_ReallyLR implicit $x069 70# UBFX needs to be selected to UBFMWri/UBFMXri, so we need constants.71 72...73---74name:            dont_combine_no_and_cst75tracksRegLiveness: true76legalized: true77body:             |78  bb.0:79    liveins: $w0, $w180 81 82    ; CHECK-LABEL: name: dont_combine_no_and_cst83    ; CHECK: liveins: $w0, $w184    ; CHECK-NEXT: {{  $}}85    ; CHECK-NEXT: %x:_(s32) = COPY $w086    ; CHECK-NEXT: %y:_(s32) = COPY $w187    ; CHECK-NEXT: %lsb:_(s32) = G_CONSTANT i32 588    ; CHECK-NEXT: %shift:_(s32) = G_LSHR %x, %lsb(s32)89    ; CHECK-NEXT: %and:_(s32) = G_AND %shift, %y90    ; CHECK-NEXT: $w0 = COPY %and(s32)91    ; CHECK-NEXT: RET_ReallyLR implicit $w092    %x:_(s32) = COPY $w093    %y:_(s32) = COPY $w194    %lsb:_(s32) = G_CONSTANT i32 595    %shift:_(s32) = G_LSHR %x, %lsb96    %and:_(s32) = G_AND %shift, %y97    $w0 = COPY %and98    RET_ReallyLR implicit $w099 100...101---102name:            dont_combine_and_cst_not_mask103tracksRegLiveness: true104legalized: true105body:             |106  bb.0:107    liveins: $w0108    ; CHECK-LABEL: name: dont_combine_and_cst_not_mask109    ; CHECK: liveins: $w0110    ; CHECK-NEXT: {{  $}}111    ; CHECK-NEXT: %x:_(s32) = COPY $w0112    ; CHECK-NEXT: %lsb:_(s32) = G_CONSTANT i32 5113    ; CHECK-NEXT: %not_a_mask:_(s32) = G_CONSTANT i32 2114    ; CHECK-NEXT: %shift:_(s32) = G_LSHR %x, %lsb(s32)115    ; CHECK-NEXT: %and:_(s32) = G_AND %shift, %not_a_mask116    ; CHECK-NEXT: $w0 = COPY %and(s32)117    ; CHECK-NEXT: RET_ReallyLR implicit $w0118    %x:_(s32) = COPY $w0119    %lsb:_(s32) = G_CONSTANT i32 5120    %not_a_mask:_(s32) = G_CONSTANT i32 2121    %shift:_(s32) = G_LSHR %x, %lsb122    %and:_(s32) = G_AND %shift, %not_a_mask123    $w0 = COPY %and124    RET_ReallyLR implicit $w0125 126...127---128name:            dont_combine_shift_more_than_one_use129tracksRegLiveness: true130legalized: true131body:             |132  bb.0:133    liveins: $x0134    ; CHECK-LABEL: name: dont_combine_shift_more_than_one_use135    ; CHECK: liveins: $x0136    ; CHECK-NEXT: {{  $}}137    ; CHECK-NEXT: %x:_(s64) = COPY $x0138    ; CHECK-NEXT: %lsb:_(s64) = G_CONSTANT i64 5139    ; CHECK-NEXT: %mask:_(s64) = G_CONSTANT i64 1140    ; CHECK-NEXT: %shift:_(s64) = G_LSHR %x, %lsb(s64)141    ; CHECK-NEXT: %and:_(s64) = G_AND %shift, %mask142    ; CHECK-NEXT: %sub:_(s64) = G_SUB %and, %shift143    ; CHECK-NEXT: $x0 = COPY %sub(s64)144    ; CHECK-NEXT: RET_ReallyLR implicit $x0145    %x:_(s64) = COPY $x0146    %lsb:_(s64) = G_CONSTANT i64 5147    %mask:_(s64) = G_CONSTANT i64 1148    %shift:_(s64) = G_LSHR %x, %lsb149    %and:_(s64) = G_AND %shift, %mask150    %sub:_(s64) = G_SUB %and, %shift151    $x0 = COPY %sub152    RET_ReallyLR implicit $x0153 154# LSB must be in [0, reg_size)155 156...157---158name:            dont_combine_negative_lsb159tracksRegLiveness: true160legalized: true161body:             |162  bb.0:163    liveins: $w0164 165 166    ; CHECK-LABEL: name: dont_combine_negative_lsb167    ; CHECK: liveins: $w0168    ; CHECK-NEXT: {{  $}}169    ; CHECK-NEXT: %x:_(s32) = COPY $w0170    ; CHECK-NEXT: %negative:_(s32) = G_CONSTANT i32 -1171    ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 255172    ; CHECK-NEXT: %shift:_(s32) = G_LSHR %x, %negative(s32)173    ; CHECK-NEXT: %and:_(s32) = G_AND %shift, %mask174    ; CHECK-NEXT: $w0 = COPY %and(s32)175    ; CHECK-NEXT: RET_ReallyLR implicit $w0176    %x:_(s32) = COPY $w0177    %negative:_(s32) = G_CONSTANT i32 -1178    %mask:_(s32) = G_CONSTANT i32 255179    %shift:_(s32) = G_LSHR %x, %negative180    %and:_(s32) = G_AND %shift, %mask181    $w0 = COPY %and182    RET_ReallyLR implicit $w0183 184# LSB must be in [0, reg_size)185 186...187---188name:            dont_combine_lsb_too_large189tracksRegLiveness: true190legalized: true191body:             |192  bb.0:193    liveins: $w0194 195 196    ; CHECK-LABEL: name: dont_combine_lsb_too_large197    ; CHECK: liveins: $w0198    ; CHECK-NEXT: {{  $}}199    ; CHECK-NEXT: %x:_(s32) = COPY $w0200    ; CHECK-NEXT: %too_large:_(s32) = G_CONSTANT i32 32201    ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 255202    ; CHECK-NEXT: %shift:_(s32) = G_LSHR %x, %too_large(s32)203    ; CHECK-NEXT: %and:_(s32) = G_AND %shift, %mask204    ; CHECK-NEXT: $w0 = COPY %and(s32)205    ; CHECK-NEXT: RET_ReallyLR implicit $w0206    %x:_(s32) = COPY $w0207    %too_large:_(s32) = G_CONSTANT i32 32208    %mask:_(s32) = G_CONSTANT i32 255209    %shift:_(s32) = G_LSHR %x, %too_large210    %and:_(s32) = G_AND %shift, %mask211    $w0 = COPY %and212    RET_ReallyLR implicit $w0213 214...215---216name:            dont_combine_vector217tracksRegLiveness: true218legalized: true219body:             |220  bb.0:221    liveins: $d0222    ; CHECK-LABEL: name: dont_combine_vector223    ; CHECK: liveins: $d0224    ; CHECK-NEXT: {{  $}}225    ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $d0226    ; CHECK-NEXT: %lsb_cst:_(s32) = G_CONSTANT i32 5227    ; CHECK-NEXT: %lsb:_(<2 x s32>) = G_BUILD_VECTOR %lsb_cst(s32), %lsb_cst(s32)228    ; CHECK-NEXT: %mask_cst:_(s32) = G_CONSTANT i32 255229    ; CHECK-NEXT: %mask:_(<2 x s32>) = G_BUILD_VECTOR %mask_cst(s32), %mask_cst(s32)230    ; CHECK-NEXT: %shift:_(<2 x s32>) = G_LSHR %x, %lsb(<2 x s32>)231    ; CHECK-NEXT: %and:_(<2 x s32>) = G_AND %shift, %mask232    ; CHECK-NEXT: $d0 = COPY %and(<2 x s32>)233    ; CHECK-NEXT: RET_ReallyLR implicit $d0234    %x:_(<2 x s32>) = COPY $d0235    %lsb_cst:_(s32) = G_CONSTANT i32 5236    %lsb:_(<2 x s32>) = G_BUILD_VECTOR %lsb_cst, %lsb_cst237    %mask_cst:_(s32) = G_CONSTANT i32 255238    %mask:_(<2 x s32>) = G_BUILD_VECTOR %mask_cst, %mask_cst239    %shift:_(<2 x s32>) = G_LSHR %x, %lsb240    %and:_(<2 x s32>) = G_AND %shift, %mask241    $d0 = COPY %and242    RET_ReallyLR implicit $d0243 244# mask = 0111 1111 1111 ... 1111245# mask + 1 = 1000 0000 0000 ... 0000246 247...248---249name:            max_signed_int_mask250tracksRegLiveness: true251legalized: true252body:             |253  bb.0:254    liveins: $x0255    ; CHECK-LABEL: name: max_signed_int_mask256    ; CHECK: liveins: $x0257    ; CHECK-NEXT: {{  $}}258    ; CHECK-NEXT: %x:_(s64) = COPY $x0259    ; CHECK-NEXT: %lsb:_(s64) = G_CONSTANT i64 0260    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63261    ; CHECK-NEXT: %and:_(s64) = G_UBFX %x, %lsb(s64), [[C]]262    ; CHECK-NEXT: $x0 = COPY %and(s64)263    ; CHECK-NEXT: RET_ReallyLR implicit $x0264    %x:_(s64) = COPY $x0265    %lsb:_(s64) = G_CONSTANT i64 0266    %mask:_(s64) = G_CONSTANT i64 9223372036854775807267    %shift:_(s64) = G_LSHR %x, %lsb268    %and:_(s64) = G_AND %shift, %mask269    $x0 = COPY %and270    RET_ReallyLR implicit $x0271 272# mask = 1111 1111 1111 ... 1111273# mask + 1 = 0000 0000 0000 ... 000274 275...276---277name:            max_unsigned_int_mask278tracksRegLiveness: true279legalized: true280body:             |281  bb.0:282    liveins: $x0283    ; CHECK-LABEL: name: max_unsigned_int_mask284    ; CHECK: liveins: $x0285    ; CHECK-NEXT: {{  $}}286    ; CHECK-NEXT: %x:_(s64) = COPY $x0287    ; CHECK-NEXT: %lsb:_(s64) = G_CONSTANT i64 5288    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64289    ; CHECK-NEXT: %and:_(s64) = G_UBFX %x, %lsb(s64), [[C]]290    ; CHECK-NEXT: $x0 = COPY %and(s64)291    ; CHECK-NEXT: RET_ReallyLR implicit $x0292    %x:_(s64) = COPY $x0293    %lsb:_(s64) = G_CONSTANT i64 5294    %mask:_(s64) = G_CONSTANT i64 18446744073709551615295    %shift:_(s64) = G_LSHR %x, %lsb296    %and:_(s64) = G_AND %shift, %mask297    $x0 = COPY %and298    RET_ReallyLR implicit $x0299