1; RUN: opt -O3 -S < %s | FileCheck %s 2 3target 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" 4target triple = "x86_64-apple-macosx10.6.7" 5 6declare i8* @malloc(i64) 7declare void @free(i8*) 8 9 10; PR2338 11define void @test1() nounwind ssp { 12 %retval = alloca i32, align 4 13 %i = alloca i8*, align 8 14 %call = call i8* @malloc(i64 1) 15 store i8* %call, i8** %i, align 8 16 %tmp = load i8*, i8** %i, align 8 17 store i8 1, i8* %tmp 18 %tmp1 = load i8*, i8** %i, align 8 19 call void @free(i8* %tmp1) 20 ret void 21 22; CHECK-LABEL: @test1( 23; CHECK-NEXT: ret void 24} 25 26; This function exposes a phase ordering problem when InstCombine is 27; turning %add into a bitmask, making it difficult to spot a 0 return value. 28; 29; It it also important that %add is expressed as a multiple of %div so scalar 30; evolution can recognize it. 31define i32 @test2(i32 %a, i32* %p) nounwind uwtable ssp { 32entry: 33 %div = udiv i32 %a, 4 34 %arrayidx = getelementptr inbounds i32, i32* %p, i64 0 35 store i32 %div, i32* %arrayidx, align 4 36 %add = add i32 %div, %div 37 %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 1 38 store i32 %add, i32* %arrayidx1, align 4 39 %arrayidx2 = getelementptr inbounds i32, i32* %p, i64 1 40 %0 = load i32, i32* %arrayidx2, align 4 41 %arrayidx3 = getelementptr inbounds i32, i32* %p, i64 0 42 %1 = load i32, i32* %arrayidx3, align 4 43 %mul = mul i32 2, %1 44 %sub = sub i32 %0, %mul 45 ret i32 %sub 46 47; CHECK-LABEL: @test2( 48; CHECK: %div = lshr i32 %a, 2 49; CHECK: %add = shl nuw nsw i32 %div, 1 50; CHECK: ret i32 0 51} 52