xref: /aosp_15_r20/external/llvm/test/CodeGen/Hexagon/builtin-prefetch-offset.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=hexagon < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; Check for the immediate offset.  It must be a multiple of 8.
3*9880d681SAndroid Build Coastguard Worker; CHECK: dcfetch({{.*}}+{{ *}}#8)
4*9880d681SAndroid Build Coastguard Worker; In 6.2 (which supports v4+ only), we generate indexed dcfetch in all cases
5*9880d681SAndroid Build Coastguard Worker; (unlike in 6.1, which supported v2, where dcfetch did not allow an immediate
6*9880d681SAndroid Build Coastguard Worker; offset).
7*9880d681SAndroid Build Coastguard Worker; For expression %2, where the offset is +9, the offset on dcfetch should be
8*9880d681SAndroid Build Coastguard Worker; a multiple of 8, and the offset of 0 is most likely (although not the only
9*9880d681SAndroid Build Coastguard Worker; possible one).  Check for #0 anyways, if the test fails with a false
10*9880d681SAndroid Build Coastguard Worker; positive, the second check can be eliminated, or rewritten, and in the
11*9880d681SAndroid Build Coastguard Worker; meantime it can help catch real problems.
12*9880d681SAndroid Build Coastguard Worker; CHECK: dcfetch({{.*}}+{{ *}}#0)
13*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
14*9880d681SAndroid Build Coastguard Workertarget triple = "hexagon"
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine void @foo(i8* %addr) nounwind {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %addr.addr = alloca i8*, align 4
19*9880d681SAndroid Build Coastguard Worker  store i8* %addr, i8** %addr.addr, align 4
20*9880d681SAndroid Build Coastguard Worker  %0 = load i8*, i8** %addr.addr, align 4
21*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr i8, i8* %0, i32 8
22*9880d681SAndroid Build Coastguard Worker  call void @llvm.prefetch(i8* %1, i32 0, i32 3, i32 1)
23*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr i8, i8* %0, i32 9
24*9880d681SAndroid Build Coastguard Worker  call void @llvm.prefetch(i8* %2, i32 0, i32 3, i32 1)
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.prefetch(i8* nocapture, i32, i32, i32) nounwind
29