1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -O3 -S < %s | FileCheck %s
4 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"
5 target triple = "x86_64-apple-macosx10.6.7"
7 declare ptr @malloc(i64)
8 declare void @free(ptr)
11 define void @test1() nounwind ssp {
12 ; CHECK-LABEL: @test1(
13 ; CHECK-NEXT: ret void
15 %retval = alloca i32, align 4
16 %i = alloca ptr, align 8
17 %call = call ptr @malloc(i64 1)
18 store ptr %call, ptr %i, align 8
19 %tmp = load ptr, ptr %i, align 8
21 %tmp1 = load ptr, ptr %i, align 8
22 call void @free(ptr %tmp1)
27 ; This function exposes a phase ordering problem when InstCombine is
28 ; turning %add into a bitmask, making it difficult to spot a 0 return value.
30 ; It it also important that %add is expressed as a multiple of %div so scalar
31 ; evolution can recognize it.
32 define i32 @test2(i32 %a, ptr %p) nounwind uwtable ssp {
33 ; CHECK-LABEL: @test2(
35 ; CHECK-NEXT: [[DIV:%.*]] = lshr i32 [[A:%.*]], 2
36 ; CHECK-NEXT: store i32 [[DIV]], ptr [[P:%.*]], align 4
37 ; CHECK-NEXT: [[ADD:%.*]] = shl nuw nsw i32 [[DIV]], 1
38 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1
39 ; CHECK-NEXT: store i32 [[ADD]], ptr [[ARRAYIDX1]], align 4
40 ; CHECK-NEXT: ret i32 0
44 store i32 %div, ptr %p, align 4
45 %add = add i32 %div, %div
46 %arrayidx1 = getelementptr inbounds i32, ptr %p, i64 1
47 store i32 %add, ptr %arrayidx1, align 4
48 %arrayidx2 = getelementptr inbounds i32, ptr %p, i64 1
49 %0 = load i32, ptr %arrayidx2, align 4
50 %1 = load i32, ptr %p, align 4
52 %sub = sub i32 %0, %mul