1 ; RUN: opt -loop-idiom -S < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
8 br label %for.body.preheader
10 for.body.preheader: ; preds = %for.cond
13 for.body: ; preds = %for.body, %for.body.preheader
14 %indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
15 %add.ptr3 = getelementptr inbounds i32, i32* null, i32 %indvars.iv
16 %add.ptr4 = getelementptr inbounds i32, i32* %add.ptr3, i32 1
17 %0 = load i32, i32* %add.ptr4, align 4
18 store i32 %0, i32* %add.ptr3, align 4
19 %indvars.iv.next = add nsw i32 %indvars.iv, 1
20 %exitcond = icmp ne i32 %indvars.iv.next, 6
21 br i1 %exitcond, label %for.body, label %for.body.preheader
24 ; CHECK-LABEL: define void @test1(
25 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 null, i8* align 4 inttoptr (i64 4 to i8*), i64 24, i1 false)
28 define void @test1_no_null_opt() #0 {
30 br label %for.body.preheader
32 for.body.preheader: ; preds = %for.cond
35 for.body: ; preds = %for.body, %for.body.preheader
36 %indvars.iv = phi i32 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
37 %add.ptr3 = getelementptr inbounds i32, i32* null, i32 %indvars.iv
38 %add.ptr4 = getelementptr inbounds i32, i32* %add.ptr3, i32 1
39 %0 = load i32, i32* %add.ptr4, align 4
40 store i32 %0, i32* %add.ptr3, align 4
41 %indvars.iv.next = add nsw i32 %indvars.iv, 1
42 %exitcond = icmp ne i32 %indvars.iv.next, 6
43 br i1 %exitcond, label %for.body, label %for.body.preheader
46 ; CHECK-LABEL: define void @test1_no_null_opt(
47 ; CHECK-NOT: call void @llvm.memcpy
48 ; CHECK: getelementptr
49 ; CHECK: getelementptr
53 attributes #0 = { "null-pointer-is-valid"="true" }