blob: 1d7a2ddc4c2d081cbc0c85a275d20117f020679b [file] [log] [blame]
Benjamin Kramer8bcc9712012-08-29 15:32:21 +00001; 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
5target 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"
6target triple = "x86_64-apple-macosx10.8.0"
7
8declare i8* @malloc(i64) nounwind
9
Benjamin Kramer2939dd32013-09-24 17:34:29 +000010define noalias i8* @test1() nounwind uwtable ssp {
Benjamin Kramer8bcc9712012-08-29 15:32:21 +000011entry:
12 %call = tail call i8* @malloc(i64 100) nounwind
David Blaikiea79ac142015-02-27 21:17:42 +000013 %0 = load i8, i8* %call, align 1
Benjamin Kramer8bcc9712012-08-29 15:32:21 +000014 %tobool = icmp eq i8 %0, 0
15 br i1 %tobool, label %if.end, label %if.then
16
17if.then: ; preds = %entry
18 store i8 0, i8* %call, align 1
19 br label %if.end
20
21if.end: ; preds = %if.then, %entry
22 ret i8* %call
23
Benjamin Kramer2939dd32013-09-24 17:34:29 +000024; CHECK-LABEL: @test1(
Benjamin Kramer8bcc9712012-08-29 15:32:21 +000025; CHECK-NOT: load
26; CHECK-NOT: icmp
27
Benjamin Kramer2939dd32013-09-24 17:34:29 +000028; CHECK_NO_LIBCALLS-LABEL: @test1(
29; CHECK_NO_LIBCALLS: load
30; CHECK_NO_LIBCALLS: icmp
31}
32
33declare i8* @_Znwm(i64) nounwind
34
35define noalias i8* @test2() nounwind uwtable ssp {
36entry:
37 %call = tail call i8* @_Znwm(i64 100) nounwind
David Blaikiea79ac142015-02-27 21:17:42 +000038 %0 = load i8, i8* %call, align 1
Benjamin Kramer2939dd32013-09-24 17:34:29 +000039 %tobool = icmp eq i8 %0, 0
40 br i1 %tobool, label %if.end, label %if.then
41
42if.then: ; preds = %entry
43 store i8 0, i8* %call, align 1
44 br label %if.end
45
46if.end: ; preds = %if.then, %entry
47 ret i8* %call
48
49; CHECK-LABEL: @test2(
50; CHECK-NOT: load
51; CHECK-NOT: icmp
52
53; CHECK_NO_LIBCALLS-LABEL: @test2(
Benjamin Kramer8bcc9712012-08-29 15:32:21 +000054; CHECK_NO_LIBCALLS: load
55; CHECK_NO_LIBCALLS: icmp
56}