1; RUN: opt -loop-idiom -S < %s | FileCheck %s 2 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-unknown-linux-gnu" 5 6define void @test1() { 7entry: 8 br label %for.body.preheader 9 10for.body.preheader: ; preds = %for.cond 11 br label %for.body 12 13for.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 22} 23 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) 26; CHECK-NOT: store 27 28define void @test1_no_null_opt() #0 { 29entry: 30 br label %for.body.preheader 31 32for.body.preheader: ; preds = %for.cond 33 br label %for.body 34 35for.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 44} 45 46; CHECK-LABEL: define void @test1_no_null_opt( 47; CHECK-NOT: call void @llvm.memcpy 48; CHECK: getelementptr 49; CHECK: getelementptr 50; CHECK: load 51; CHECK: store 52 53attributes #0 = { null_pointer_is_valid } 54