xref: /aosp_15_r20/external/llvm/test/CodeGen/Lanai/subword.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=lanai-unknown-unknown | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Test scheduling of subwords.
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker%struct.X = type { i16, i16 }
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workerdefine void @f(%struct.X* inreg nocapture %c) #0 {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker  %a = getelementptr inbounds %struct.X, %struct.X* %c, i32 0, i32 0
10*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* %a, align 2
11*9880d681SAndroid Build Coastguard Worker  %inc = add i16 %0, 1
12*9880d681SAndroid Build Coastguard Worker  store i16 %inc, i16* %a, align 2
13*9880d681SAndroid Build Coastguard Worker  %b = getelementptr inbounds %struct.X, %struct.X* %c, i32 0, i32 1
14*9880d681SAndroid Build Coastguard Worker  %1 = load i16, i16* %b, align 2
15*9880d681SAndroid Build Coastguard Worker  %dec = add i16 %1, -1
16*9880d681SAndroid Build Coastguard Worker  store i16 %dec, i16* %b, align 2
17*9880d681SAndroid Build Coastguard Worker  ret void
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; Verify that the two loads occur before the stores. Without memory
21*9880d681SAndroid Build Coastguard Worker; disambiguation and subword schedule, the resultant code was a per subword
22*9880d681SAndroid Build Coastguard Worker; load-modify-store sequence instead of the more optimal schedule where all
23*9880d681SAndroid Build Coastguard Worker; loads occurred before modification and storage.
24*9880d681SAndroid Build Coastguard Worker; CHECK:      uld.h
25*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: uld.h
26*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: add
27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: st.h
28*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: sub
29*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: st.h
30