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
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 }
11 name: not_necessarily_equiv_loads
12 tracksRegLiveness: true
13 machineFunctionInfo: {}
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.
21 ; Check that we don't remove the G_OR.
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 (s32) from @g)
26 ; CHECK: %load2:_(s32) = G_LOAD %ptr(p0) :: (load (s32) from @g)
27 ; CHECK: %or:_(s32) = G_OR %load2, %load1
28 ; CHECK: G_STORE %or(s32), %ptr(p0) :: (store (s32) into @g)
30 %ptr:_(p0) = G_GLOBAL_VALUE @g
31 %load1:_(s32) = G_LOAD %ptr(p0) :: (load (s32) from @g)
32 %load2:_(s32) = G_LOAD %ptr(p0) :: (load (s32) from @g)
33 %or:_(s32) = G_OR %load2, %load1
34 G_STORE %or(s32), %ptr(p0) :: (store (s32) into @g)
40 tracksRegLiveness: true
41 machineFunctionInfo: {}
45 ; %load1 || %load2 == %load1 is fine here, because the loads are invariant.
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 (s32) from @g)
50 ; CHECK: G_STORE %load2(s32), %ptr(p0) :: (store (s32) into @g)
52 %ptr:_(p0) = G_GLOBAL_VALUE @g
53 %load1:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load (s32) from @g)
54 %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load (s32) from @g)
55 %or:_(s32) = G_OR %load2, %load1
56 G_STORE %or(s32), %ptr(p0) :: (store (s32) into @g)
61 name: both_have_to_be_invariant
62 tracksRegLiveness: true
63 machineFunctionInfo: {}
67 ; We shouldn't combine here, because the loads both have to be invariant.
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 (s32) from @g)
72 ; CHECK: %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable load (s32) from @g)
73 ; CHECK: %or:_(s32) = G_OR %load2, %load1
74 ; CHECK: G_STORE %or(s32), %ptr(p0) :: (store (s32) into @g)
76 %ptr:_(p0) = G_GLOBAL_VALUE @g
77 %load1:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable invariant load (s32) from @g)
78 %load2:_(s32) = G_LOAD %ptr(p0) :: (dereferenceable load (s32) from @g)
79 %or:_(s32) = G_OR %load2, %load1
80 G_STORE %or(s32), %ptr(p0) :: (store (s32) into @g)