~ubuntu-branches/ubuntu/quantal/llvm-3.1/quantal

« back to all changes in this revision

Viewing changes to test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-03-29 19:09:51 UTC
  • Revision ID: package-import@ubuntu.com-20120329190951-aq83ivog4cg8bxun
Tags: upstream-3.1~svn153643
ImportĀ upstreamĀ versionĀ 3.1~svn153643

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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"
 
4
 
 
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
 
13
 
 
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
 
23
  br label %10
 
24
 
 
25
; <label>:10                                      ; preds = %4, %0
 
26
  %11 = load double** %ptr, align 4
 
27
  call void @bar(double* %11)
 
28
; CHECK: ret
 
29
  ret void
 
30
}
 
31
 
 
32
declare void @bar(double*)
 
33
 
 
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
 
42
 
 
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:
 
47
  %7 = add  i32 %6, 2048
 
48
; CHECK: alloca i8
 
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
 
53
  br label %10
 
54
 
 
55
; <label>:10                                      ; preds = %4, %0
 
56
  %11 = load double** %ptr, align 4
 
57
  call void @bar(double* %11)
 
58
  ret void
 
59
}
 
60