66b6929d3038d7eb49d1635b3ca4c32793178d51
[oota-llvm.git] / test / Transforms / GVN / malloc-load-removal.ll
1 ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
2 ; RUN: opt -S -basicaa -gvn -disable-simplify-libcalls < %s | FileCheck %s -check-prefix=CHECK_NO_LIBCALLS
3 ; PR13694
4
5 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-S128"
6 target triple = "x86_64-apple-macosx10.8.0"
7
8 declare i8* @malloc(i64) nounwind
9
10 define noalias i8* @test() nounwind uwtable ssp {
11 entry:
12   %call = tail call i8* @malloc(i64 100) nounwind
13   %0 = load i8* %call, align 1
14   %tobool = icmp eq i8 %0, 0
15   br i1 %tobool, label %if.end, label %if.then
16
17 if.then:                                          ; preds = %entry
18   store i8 0, i8* %call, align 1
19   br label %if.end
20
21 if.end:                                           ; preds = %if.then, %entry
22   ret i8* %call
23
24 ; CHECK: @test
25 ; CHECK-NOT: load
26 ; CHECK-NOT: icmp
27
28 ; CHECK_NO_LIBCALLS: @test
29 ; CHECK_NO_LIBCALLS: load
30 ; CHECK_NO_LIBCALLS: icmp
31 }