1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
3 target triple = "i386-apple-darwin10.0.0"
5 define void @fu1(i32 %parm) nounwind ssp {
6 %1 = alloca i32, align 4
7 %ptr = alloca double*, align 4
8 store i32 %parm, i32* %1, align 4
9 store double* null, double** %ptr, align 4
10 %2 = load i32* %1, align 4
11 %3 = icmp ne i32 %2, 0
12 br i1 %3, label %4, label %10
14 ; <label>:4 ; preds = %0
15 %5 = load i32* %1, align 4
16 %6 = mul nsw i32 %5, 8
17 ; With "nsw", the alloca and its bitcast can be fused:
18 %7 = add nsw i32 %6, 2048
19 ; CHECK: alloca double*
20 %8 = alloca i8, i32 %7
21 %9 = bitcast i8* %8 to double*
22 store double* %9, double** %ptr, align 4
25 ; <label>:10 ; preds = %4, %0
26 %11 = load double** %ptr, align 4
27 call void @bar(double* %11)
32 declare void @bar(double*)
34 define void @fu2(i32 %parm) nounwind ssp {
35 %1 = alloca i32, align 4
36 %ptr = alloca double*, align 4
37 store i32 %parm, i32* %1, align 4
38 store double* null, double** %ptr, align 4
39 %2 = load i32* %1, align 4
40 %3 = icmp ne i32 %2, 0
41 br i1 %3, label %4, label %10
43 ; <label>:4 ; preds = %0
44 %5 = load i32* %1, align 4
45 %6 = mul nsw i32 %5, 8
46 ; Without "nsw", the alloca and its bitcast cannot be fused:
49 %8 = alloca i8, i32 %7
50 ; CHECK-NEXT: bitcast i8*
51 %9 = bitcast i8* %8 to double*
52 store double* %9, double** %ptr, align 4
55 ; <label>:10 ; preds = %4, %0
56 %11 = load double** %ptr, align 4
57 call void @bar(double* %11)