xref: /llvm-project/llvm/test/CodeGen/Hexagon/loop-idiom/hexagon-memmove2.ll (revision ef57977f2aa32661a09fa6538f47ddee0a004d11)
1; RUN: opt -hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
2; RUN:  | FileCheck %s
3; RUN: opt -p hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
4; RUN:  | FileCheck %s
5
6define void @PR14241(ptr %s, i64 %size) #0 {
7; Ensure that we don't form a memcpy for strided loops. Briefly, when we taught
8; LoopIdiom about memmove and strided loops, this got miscompiled into a memcpy
9; instead of a memmove. If we get the memmove transform back, this will catch
10; regressions.
11;
12; CHECK-LABEL: @PR14241(
13
14entry:
15  %end.idx = add i64 %size, -1
16  %end.ptr = getelementptr inbounds i32, ptr %s, i64 %end.idx
17  br label %while.body
18; CHECK-NOT: memcpy
19; CHECK: memmove
20
21while.body:
22  %phi.ptr = phi ptr [ %s, %entry ], [ %next.ptr, %while.body ]
23  %src.ptr = getelementptr inbounds i32, ptr %phi.ptr, i64 1
24  %val = load i32, ptr %src.ptr, align 4
25; CHECK: load
26  store i32 %val, ptr %phi.ptr, align 4
27; CHECK: store
28  %next.ptr = getelementptr inbounds i32, ptr %phi.ptr, i64 1
29  %cmp = icmp eq ptr %next.ptr, %end.ptr
30  br i1 %cmp, label %exit, label %while.body
31
32exit:
33  ret void
34; CHECK: ret void
35}
36
37attributes #0 = { nounwind }
38