1 ; RUN: opt -basicaa -loop-idiom < %s -S | FileCheck %s
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4 ; CHECK: @.memset_pattern = private unnamed_addr constant [4 x i32] [i32 2, i32 2, i32 2, i32 2], align 16
6 target triple = "x86_64-apple-darwin10.0.0"
8 ;void test(int *f, unsigned n) {
9 ; for (unsigned i = 0; i < 2 * n; i += 2) {
14 define void @test(i32* %f, i32 %n) nounwind ssp {
17 %cmp1 = icmp eq i32 %mul, 0
18 br i1 %cmp1, label %for.end, label %for.body.preheader
20 for.body.preheader: ; preds = %entry
21 %0 = zext i32 %mul to i64
24 for.body: ; preds = %for.body.preheader, %for.body
25 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
26 %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv
27 store i32 0, i32* %arrayidx, align 4
28 %1 = or i64 %indvars.iv, 1
29 %arrayidx2 = getelementptr inbounds i32, i32* %f, i64 %1
30 store i32 0, i32* %arrayidx2, align 4
31 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
32 %cmp = icmp ult i64 %indvars.iv.next, %0
33 br i1 %cmp, label %for.body, label %for.end.loopexit
35 for.end.loopexit: ; preds = %for.body
38 for.end: ; preds = %for.end.loopexit, %entry
41 ; CHECK: call void @llvm.memset
45 ;void test_pattern(int *f, unsigned n) {
46 ; for (unsigned i = 0; i < 2 * n; i += 2) {
51 define void @test_pattern(i32* %f, i32 %n) nounwind ssp {
54 %cmp1 = icmp eq i32 %mul, 0
55 br i1 %cmp1, label %for.end, label %for.body.preheader
57 for.body.preheader: ; preds = %entry
58 %0 = zext i32 %mul to i64
61 for.body: ; preds = %for.body.preheader, %for.body
62 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
63 %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv
64 store i32 2, i32* %arrayidx, align 4
65 %1 = or i64 %indvars.iv, 1
66 %arrayidx2 = getelementptr inbounds i32, i32* %f, i64 %1
67 store i32 2, i32* %arrayidx2, align 4
68 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
69 %cmp = icmp ult i64 %indvars.iv.next, %0
70 br i1 %cmp, label %for.body, label %for.end.loopexit
72 for.end.loopexit: ; preds = %for.body
75 for.end: ; preds = %for.end.loopexit, %entry
77 ; CHECK-LABEL: @test_pattern(
78 ; CHECK: call void @memset_pattern16