1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s 3 4--- | 5 @g = external hidden unnamed_addr global i32, align 4 6 define void @not_necessarily_equiv_loads() { ret void } 7 define void @invariant_loads() { ret void } 8 define void @both_have_to_be_invariant() { ret void } 9... 10--- 11name: not_necessarily_equiv_loads 12tracksRegLiveness: true 13machineFunctionInfo: {} 14body: | 15 bb.0: 16 17 ; %load1 || %load2 == %load1 is not necessarily true, even though they 18 ; both load from the same address. Whatever is in that address may be 19 ; changed by another instruction which appears between them. 20 ; 21 ; Check that we don't remove the G_OR. 22 23 ; CHECK-LABEL: name: not_necessarily_equiv_loads 24 ; CHECK: %ptr:_(p0) = G_GLOBAL_VALUE @g 25 ; CHECK: %load1:_(s32) = G_LOAD %ptr(p0) :: (load 4 from @g) 26 ; CHECK: %load2:_(s32) = G_LOAD %ptr(p0) :: (load 4 from @g) 27 ; CHECK: %or:_(s32) = G_OR %load2, %load1 28 ; CHECK: G_STORE %or(s32), %ptr(p0) :: (store 4 into @g) 29 ; CHECK: RET_ReallyLR 30 %ptr:_(p0) = G_GLOBAL_VALUE @g 31 %load1:_(s32) = G_LOAD %ptr(p0) :: (load 4 from @g) 32 %load2:_(s32) = G_LOAD %ptr(p0) :: (load 4 from @g) 33 %or:_(s32) = G_OR %load2, %load1 34 G_STORE %or(s32), %ptr(p0) :: (store 4 into @g) 35 RET_ReallyLR 36 37... 38--- 39name: invariant_loads 40tracksRegLiveness: true 41machineFunctionInfo: {} 42body: | 43 bb.0: 44 45 ; %load1 || %load2 == %load1 is fine here, because the loads are invariant. 46 47 ; CHECK-LABEL: name: invariant_loads 48 ; CHECK: %ptr:_(p0) = G_GLOBAL_VALUE @g 49 ; CHECK: %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load 4 from @g) 50 ; CHECK: G_STORE %load2(s32), %ptr(p0) :: (store 4 into @g) 51 ; CHECK: RET_ReallyLR 52 %ptr:_(p0) = G_GLOBAL_VALUE @g 53 %load1:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load 4 from @g) 54 %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load 4 from @g) 55 %or:_(s32) = G_OR %load2, %load1 56 G_STORE %or(s32), %ptr(p0) :: (store 4 into @g) 57 RET_ReallyLR 58 59... 60--- 61name: both_have_to_be_invariant 62tracksRegLiveness: true 63machineFunctionInfo: {} 64body: | 65 bb.0: 66 67 ; We shouldn't combine here, because the loads both have to be invariant. 68 69 ; CHECK-LABEL: name: both_have_to_be_invariant 70 ; CHECK: %ptr:_(p0) = G_GLOBAL_VALUE @g 71 ; CHECK: %load1:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load 4 from @g) 72 ; CHECK: %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable load 4 from @g) 73 ; CHECK: %or:_(s32) = G_OR %load2, %load1 74 ; CHECK: G_STORE %or(s32), %ptr(p0) :: (store 4 into @g) 75 ; CHECK: RET_ReallyLR 76 %ptr:_(p0) = G_GLOBAL_VALUE @g 77 %load1:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load 4 from @g) 78 %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable load 4 from @g) 79 %or:_(s32) = G_OR %load2, %load1 80 G_STORE %or(s32), %ptr(p0) :: (store 4 into @g) 81 RET_ReallyLR 82... 83