1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
3
4define void @merge_store(i32* nocapture %a) {
5; CHECK-LABEL: merge_store:
6; CHECK:       # %bb.0: # %entry
7; CHECK-NEXT:    xorl %eax, %eax
8; CHECK-NEXT:    movabsq $4294967297, %rcx # imm = 0x100000001
9; CHECK-NEXT:    .p2align 4, 0x90
10; CHECK-NEXT:  .LBB0_1: # %for.body
11; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
12; CHECK-NEXT:    movq %rcx, (%rdi,%rax,4)
13; CHECK-NEXT:    movq %rcx, 8(%rdi,%rax,4)
14; CHECK-NEXT:    addq $4, %rax
15; CHECK-NEXT:    cmpl $1000, %eax # imm = 0x3E8
16; CHECK-NEXT:    jl .LBB0_1
17; CHECK-NEXT:  # %bb.2: # %for.end
18; CHECK-NEXT:    retq
19entry:
20  br label %for.body
21
22  for.body:
23  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
24  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
25  store i32 1, i32* %arrayidx, align 4
26  %0 = or i64 %indvars.iv, 1
27  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %0
28  store i32 1, i32* %arrayidx2, align 4
29  %1 = or i64 %indvars.iv, 2
30  %arrayidx5 = getelementptr inbounds i32, i32* %a, i64 %1
31  store i32 1, i32* %arrayidx5, align 4
32  %2 = or i64 %indvars.iv, 3
33  %arrayidx8 = getelementptr inbounds i32, i32* %a, i64 %2
34  store i32 1, i32* %arrayidx8, align 4
35  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
36  %3 = trunc i64 %indvars.iv.next to i32
37  %cmp = icmp slt i32 %3, 1000
38  br i1 %cmp, label %for.body, label %for.end
39
40  for.end:
41  ret void
42}
43
44define void @indexed_store_merge(i64 %p, i8* %v) {
45; CHECK-LABEL: indexed_store_merge:
46; CHECK:       # %bb.0: # %entry
47; CHECK-NEXT:    movl $0, 2(%rdi,%rsi)
48; CHECK-NEXT:    movb $0, (%rsi)
49; CHECK-NEXT:    retq
50entry:
51  %p2 = add nsw i64 %p, 2
52  %v2 = getelementptr i8, i8* %v, i64 %p2
53  store i8 0, i8* %v2, align 2
54  %p3 = add nsw i64 %p, 3
55  %v3 = getelementptr i8, i8* %v, i64 %p3
56  store i8 0, i8* %v3, align 1
57  %p4 = add nsw i64 %p, 4
58  %v4 = getelementptr i8, i8* %v, i64 %p4
59  store i8 0, i8* %v4, align 2
60  %p5 = add nsw i64 %p, 5
61  %v5 = getelementptr i8, i8* %v, i64 %p5
62  store i8 0, i8* %v5, align 1
63  %v0 = getelementptr i8, i8* %v, i64 0
64  store i8 0, i8* %v0, align 2
65  ret void
66}
67