brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.0 KiB · f0fbfec Raw
310 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -mtriple aarch64-apple-darwin -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s3 4--- |5    @g = external hidden global i326 7    %opaque = type opaque8    @unsized = external hidden global %opaque9    @thread_local = thread_local global i32 010 11    define void @one_ptr_add() { ret void }12    define void @add_to_offset() { ret void }13    define void @two_ptr_adds_same_offset() { ret void }14    define void @two_ptr_adds_different_offset() { ret void }15    define void @ptr_add_chain() { ret void }16 17    define void @dont_fold_negative_offset() { ret void }18    define void @dont_min_offset_less_than_curr_offset() { ret void }19    define void @dont_fold_max_offset() { ret void }20    define void @dont_fold_offset_larger_than_type_alloc() { ret void }21    define void @dont_fold_unsized_type() { ret void }22    define void @dont_fold_thread_local() { ret void }23...24# We should fold the offset 1 into the G_GLOBAL_VALUE.25---26name:            one_ptr_add27alignment:       428tracksRegLiveness: true29machineFunctionInfo: {}30body:             |31  bb.0:32    liveins: $x033 34    ; CHECK-LABEL: name: one_ptr_add35    ; CHECK: liveins: $x036    ; CHECK-NEXT: {{  $}}37    ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @g + 138    ; CHECK-NEXT: $x0 = COPY [[GV]](p0)39    ; CHECK-NEXT: RET_ReallyLR implicit $x040    %global:_(p0) = G_GLOBAL_VALUE @g41    %offset:_(s64) = G_CONSTANT i64 142    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)43    $x0 = COPY %ptr_add44    RET_ReallyLR implicit $x045 46...47# We should fold the offset 1 into the G_GLOBAL_VALUE, resulting in a48# final offset of 4.49---50name:            add_to_offset51alignment:       452tracksRegLiveness: true53machineFunctionInfo: {}54body:             |55  bb.0:56    liveins: $x057 58    ; CHECK-LABEL: name: add_to_offset59    ; CHECK: liveins: $x060    ; CHECK-NEXT: {{  $}}61    ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @g + 462    ; CHECK-NEXT: $x0 = COPY [[GV]](p0)63    ; CHECK-NEXT: RET_ReallyLR implicit $x064    %global:_(p0) = G_GLOBAL_VALUE @g + 365    %offset:_(s64) = G_CONSTANT i64 166    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)67    $x0 = COPY %ptr_add68    RET_ReallyLR implicit $x069 70...71# We're allowed to have more than one G_PTR_ADD use. We should fold 1 into72# the G_GLOBAL_VALUE's offset.73---74name:            two_ptr_adds_same_offset75alignment:       476tracksRegLiveness: true77machineFunctionInfo: {}78body:             |79  bb.0:80    liveins: $x0, $x181 82    ; CHECK-LABEL: name: two_ptr_adds_same_offset83    ; CHECK: liveins: $x0, $x184    ; CHECK-NEXT: {{  $}}85    ; CHECK-NEXT: %val1:_(s64) = COPY $x086    ; CHECK-NEXT: %val2:_(s64) = COPY $x187    ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @g + 188    ; CHECK-NEXT: G_STORE %val1(s64), [[GV]](p0) :: (store (s64))89    ; CHECK-NEXT: G_STORE %val2(s64), [[GV]](p0) :: (store (s64))90    ; CHECK-NEXT: RET_ReallyLR implicit $x091    %val1:_(s64) = COPY $x092    %val2:_(s64) = COPY $x193    %global:_(p0) = G_GLOBAL_VALUE @g94    %offset:_(s64) = G_CONSTANT i64 195    %ptr_add1:_(p0) = G_PTR_ADD %global, %offset(s64)96    %ptr_add2:_(p0) = G_PTR_ADD %global, %offset(s64)97    G_STORE %val1:_(s64), %ptr_add1 :: (store (s64))98    G_STORE %val2:_(s64), %ptr_add2 :: (store (s64))99    RET_ReallyLR implicit $x0100 101...102# The lowest offset G_PTR_ADD (2) should be folded into the G_GLOBAL_VALUE.103#104# The other G_PTR_ADD should have its offset decremented by 2.105---106name:            two_ptr_adds_different_offset107alignment:       4108tracksRegLiveness: true109machineFunctionInfo: {}110body:             |111  bb.0:112    liveins: $x0, $x1113 114    ; CHECK-LABEL: name: two_ptr_adds_different_offset115    ; CHECK: liveins: $x0, $x1116    ; CHECK-NEXT: {{  $}}117    ; CHECK-NEXT: %val1:_(s64) = COPY $x0118    ; CHECK-NEXT: %val2:_(s64) = COPY $x1119    ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @g + 2120    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8121    ; CHECK-NEXT: %ptr_add2:_(p0) = G_PTR_ADD [[GV]], [[C]](s64)122    ; CHECK-NEXT: G_STORE %val1(s64), [[GV]](p0) :: (store (s64))123    ; CHECK-NEXT: G_STORE %val2(s64), %ptr_add2(p0) :: (store (s64))124    ; CHECK-NEXT: RET_ReallyLR implicit $x0125    %val1:_(s64) = COPY $x0126    %val2:_(s64) = COPY $x1127    %global:_(p0) = G_GLOBAL_VALUE @g128    %offset1:_(s64) = G_CONSTANT i64 2129    %offset2:_(s64) = G_CONSTANT i64 10130    %ptr_add1:_(p0) = G_PTR_ADD %global, %offset1(s64)131    %ptr_add2:_(p0) = G_PTR_ADD %global, %offset2(s64)132    G_STORE %val1:_(s64), %ptr_add1 :: (store (s64))133    G_STORE %val2:_(s64), %ptr_add2 :: (store (s64))134    RET_ReallyLR implicit $x0135 136...137# We should be able to fold all of the G_PTR_ADDs, except for the last one138# into the G_GLOBAL_VALUE.139#140# (TypeAllocSize = 4, so the offset on the G_GLOBAL_VALUE can't go above141# that.)142---143name:            ptr_add_chain144alignment:       4145tracksRegLiveness: true146machineFunctionInfo: {}147body:             |148  bb.0:149    liveins: $x0150 151    ; CHECK-LABEL: name: ptr_add_chain152    ; CHECK: liveins: $x0153    ; CHECK-NEXT: {{  $}}154    ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @g + 4155    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 1156    ; CHECK-NEXT: %dont_fold_me:_(p0) = G_PTR_ADD [[GV]], %offset(s64)157    ; CHECK-NEXT: $x0 = COPY %dont_fold_me(p0)158    ; CHECK-NEXT: RET_ReallyLR implicit $x0159    %global:_(p0) = G_GLOBAL_VALUE @g160    %offset:_(s64) = G_CONSTANT i64 1161    %ptr_add1:_(p0) = G_PTR_ADD %global, %offset(s64)162    %ptr_add2:_(p0) = G_PTR_ADD %ptr_add1, %offset(s64)163    %ptr_add3:_(p0) = G_PTR_ADD %ptr_add2, %offset(s64)164    %ptr_add4:_(p0) = G_PTR_ADD %ptr_add3, %offset(s64)165    %dont_fold_me:_(p0) = G_PTR_ADD %ptr_add4, %offset(s64)166    $x0 = COPY %dont_fold_me167    RET_ReallyLR implicit $x0168 169...170# Do not add negative offsets to G_GLOBAL_VALUE.171---172name:            dont_fold_negative_offset173alignment:       4174tracksRegLiveness: true175machineFunctionInfo: {}176body:             |177  bb.0:178    liveins: $x0179 180    ; CHECK-LABEL: name: dont_fold_negative_offset181    ; CHECK: liveins: $x0182    ; CHECK-NEXT: {{  $}}183    ; CHECK-NEXT: %global:_(p0) = G_GLOBAL_VALUE @g184    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 -1185    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)186    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)187    ; CHECK-NEXT: RET_ReallyLR implicit $x0188    %global:_(p0) = G_GLOBAL_VALUE @g189    %offset:_(s64) = G_CONSTANT i64 -1190    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)191    $x0 = COPY %ptr_add192    RET_ReallyLR implicit $x0193 194...195# Do not create smaller offsets. Ensures combine termination.196---197name:            dont_min_offset_less_than_curr_offset198alignment:       4199tracksRegLiveness: true200machineFunctionInfo: {}201body:             |202  bb.0:203    liveins: $x0204 205    ; CHECK-LABEL: name: dont_min_offset_less_than_curr_offset206    ; CHECK: liveins: $x0207    ; CHECK-NEXT: {{  $}}208    ; CHECK-NEXT: %global:_(p0) = G_GLOBAL_VALUE @g + 3209    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 -1210    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)211    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)212    ; CHECK-NEXT: RET_ReallyLR implicit $x0213    %global:_(p0) = G_GLOBAL_VALUE @g + 3214    %offset:_(s64) = G_CONSTANT i64 -1215    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)216    $x0 = COPY %ptr_add217    RET_ReallyLR implicit $x0218 219...220# 1 << 21 is the largest offset expressible in all object formats.221# Don't fold it.222---223name:            dont_fold_max_offset224alignment:       4225tracksRegLiveness: true226machineFunctionInfo: {}227body:             |228  bb.0:229    liveins: $x0230 231    ; CHECK-LABEL: name: dont_fold_max_offset232    ; CHECK: liveins: $x0233    ; CHECK-NEXT: {{  $}}234    ; CHECK-NEXT: %global:_(p0) = G_GLOBAL_VALUE @g235    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 4292870144236    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)237    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)238    ; CHECK-NEXT: RET_ReallyLR implicit $x0239    %global:_(p0) = G_GLOBAL_VALUE @g240    %offset:_(s64) = G_CONSTANT i64 4292870144 ; 1 << 21241    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)242    $x0 = COPY %ptr_add243    RET_ReallyLR implicit $x0244 245...246# Type alloc size = 4, offset = 16. Don't fold.247---248name:            dont_fold_offset_larger_than_type_alloc249alignment:       4250tracksRegLiveness: true251machineFunctionInfo: {}252body:             |253  bb.0:254 255    ; CHECK-LABEL: name: dont_fold_offset_larger_than_type_alloc256    ; CHECK: %global:_(p0) = G_GLOBAL_VALUE @g257    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 16258    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)259    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)260    ; CHECK-NEXT: RET_ReallyLR implicit $x0261    %global:_(p0) = G_GLOBAL_VALUE @g262    %offset:_(s64) = G_CONSTANT i64 16263    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)264    $x0 = COPY %ptr_add(p0)265    RET_ReallyLR implicit $x0266 267...268# Check that we don't touch unsized globals.269---270name:            dont_fold_unsized_type271alignment:       4272tracksRegLiveness: true273machineFunctionInfo: {}274body:             |275  bb.0:276 277    ; CHECK-LABEL: name: dont_fold_unsized_type278    ; CHECK: %global:_(p0) = G_GLOBAL_VALUE @unsized279    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 16280    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)281    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)282    ; CHECK-NEXT: RET_ReallyLR implicit $x0283    %global:_(p0) = G_GLOBAL_VALUE @unsized284    %offset:_(s64) = G_CONSTANT i64 16285    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)286    $x0 = COPY %ptr_add(p0)287    RET_ReallyLR implicit $x0288 289...290# Check that we don't touch thread-local globals.291---292name:            dont_fold_thread_local293alignment:       4294tracksRegLiveness: true295machineFunctionInfo: {}296body:             |297  bb.0:298 299    ; CHECK-LABEL: name: dont_fold_thread_local300    ; CHECK: %global:_(p0) = G_GLOBAL_VALUE @thread_local301    ; CHECK-NEXT: %offset:_(s64) = G_CONSTANT i64 16302    ; CHECK-NEXT: %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)303    ; CHECK-NEXT: $x0 = COPY %ptr_add(p0)304    ; CHECK-NEXT: RET_ReallyLR implicit $x0305    %global:_(p0) = G_GLOBAL_VALUE @thread_local306    %offset:_(s64) = G_CONSTANT i64 16307    %ptr_add:_(p0) = G_PTR_ADD %global, %offset(s64)308    $x0 = COPY %ptr_add(p0)309    RET_ReallyLR implicit $x0310