diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
commit | 63faed5b8e4f2755f127fcb8aa440480c0649327 (patch) | |
tree | 19c69a04768629f2d440944b71cbe90adae0b615 /test/Transforms/LICM | |
parent | d4c8b5d2e851b0e8a063c6bf8543a4823a26c15a (diff) | |
download | src-63faed5b8e4f2755f127fcb8aa440480c0649327.tar.gz src-63faed5b8e4f2755f127fcb8aa440480c0649327.zip |
Vendor import of llvm trunk r154661:vendor/llvm/llvm-trunk-r154661
Notes
Notes:
svn path=/vendor/llvm/dist/; revision=234285
svn path=/vendor/llvm/llvm-trunk-r154661/; revision=234286; tag=vendor/llvm/llvm-trunk-r154661
Diffstat (limited to 'test/Transforms/LICM')
-rw-r--r-- | test/Transforms/LICM/2007-05-22-VolatileSink.ll | 4 | ||||
-rw-r--r-- | test/Transforms/LICM/2011-04-06-HoistMissedASTUpdate.ll | 2 | ||||
-rw-r--r-- | test/Transforms/LICM/crash.ll | 2 | ||||
-rw-r--r-- | test/Transforms/LICM/dg.exp | 3 | ||||
-rw-r--r-- | test/Transforms/LICM/hoist-invariant-load.ll | 39 | ||||
-rw-r--r-- | test/Transforms/LICM/lit.local.cfg | 1 | ||||
-rw-r--r-- | test/Transforms/LICM/scalar_promote.ll | 4 | ||||
-rw-r--r-- | test/Transforms/LICM/speculate.ll | 167 |
8 files changed, 213 insertions, 9 deletions
diff --git a/test/Transforms/LICM/2007-05-22-VolatileSink.ll b/test/Transforms/LICM/2007-05-22-VolatileSink.ll index 17383c2ebb63..4df6ea758103 100644 --- a/test/Transforms/LICM/2007-05-22-VolatileSink.ll +++ b/test/Transforms/LICM/2007-05-22-VolatileSink.ll @@ -10,7 +10,7 @@ entry: br label %bb6 bb: ; preds = %bb6 - %tmp2 = volatile load i32* %DataIn ; <i32> [#uses=1] + %tmp2 = load volatile i32* %DataIn ; <i32> [#uses=1] %tmp3 = getelementptr [64 x i32]* %buffer, i32 0, i32 %i.0 ; <i32*> [#uses=1] store i32 %tmp2, i32* %tmp3 %tmp5 = add i32 %i.0, 1 ; <i32> [#uses=1] @@ -28,7 +28,7 @@ bb12: ; preds = %bb22 %tmp16 = add i32 %tmp14, %i.1 ; <i32> [#uses=1] %tmp17 = getelementptr [64 x i32]* %buffer, i32 0, i32 %tmp16 ; <i32*> [#uses=1] %tmp18 = load i32* %tmp17 ; <i32> [#uses=1] - volatile store i32 %tmp18, i32* %DataOut + store volatile i32 %tmp18, i32* %DataOut %tmp21 = add i32 %j.1, 1 ; <i32> [#uses=1] br label %bb22 diff --git a/test/Transforms/LICM/2011-04-06-HoistMissedASTUpdate.ll b/test/Transforms/LICM/2011-04-06-HoistMissedASTUpdate.ll index fd114f4ccc11..2bbc6ab0414a 100644 --- a/test/Transforms/LICM/2011-04-06-HoistMissedASTUpdate.ll +++ b/test/Transforms/LICM/2011-04-06-HoistMissedASTUpdate.ll @@ -19,7 +19,7 @@ for.body4.lr.ph: for.body4: %l_612.11 = phi i32* [ undef, %for.body4.lr.ph ], [ %call19, %for.body4 ] - %tmp7 = volatile load i16* @g_39, align 2 + %tmp7 = load volatile i16* @g_39, align 2 %call = call i32** @func_108(i32*** undef) %call19 = call i32* @func_84(i32** %call) br i1 false, label %for.body4, label %for.cond.loopexit diff --git a/test/Transforms/LICM/crash.ll b/test/Transforms/LICM/crash.ll index ff7fa0b19a82..de41d008a746 100644 --- a/test/Transforms/LICM/crash.ll +++ b/test/Transforms/LICM/crash.ll @@ -68,7 +68,7 @@ define void @test4() noreturn nounwind { br label %1 ; <label>:1 ; preds = %1, %0 - volatile store i32* @g_47, i32** undef, align 8 + store volatile i32* @g_47, i32** undef, align 8 store i32 undef, i32* @g_47, align 4 br label %1 } diff --git a/test/Transforms/LICM/dg.exp b/test/Transforms/LICM/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/LICM/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/LICM/hoist-invariant-load.ll b/test/Transforms/LICM/hoist-invariant-load.ll new file mode 100644 index 000000000000..4e100d3aee34 --- /dev/null +++ b/test/Transforms/LICM/hoist-invariant-load.ll @@ -0,0 +1,39 @@ +; RUN: opt < %s -licm -stats -S |& grep "1 licm" + +@"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"foo\00", section "__TEXT,__objc_methname,cstring_literals", align 1 +@"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" +@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip" +@llvm.used = appending global [3 x i8*] [i8* getelementptr inbounds ([4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_" to i8*), i8* bitcast ([2 x i32]* @"\01L_OBJC_IMAGE_INFO" to i8*)], section "llvm.metadata" + +define void @test(i8* %x) uwtable ssp { +entry: + %x.addr = alloca i8*, align 8 + %i = alloca i32, align 4 + store i8* %x, i8** %x.addr, align 8 + store i32 0, i32* %i, align 4 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %0 = load i32* %i, align 4 + %cmp = icmp ult i32 %0, 10000 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %1 = load i8** %x.addr, align 8 + %2 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load !0 + %call = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %1, i8* %2) + br label %for.inc + +for.inc: ; preds = %for.body + %3 = load i32* %i, align 4 + %inc = add i32 %3, 1 + store i32 %inc, i32* %i, align 4 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind + +!0 = metadata !{} diff --git a/test/Transforms/LICM/lit.local.cfg b/test/Transforms/LICM/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/LICM/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/LICM/scalar_promote.ll b/test/Transforms/LICM/scalar_promote.ll index 9aefc4f87eac..05a64d632274 100644 --- a/test/Transforms/LICM/scalar_promote.ll +++ b/test/Transforms/LICM/scalar_promote.ll @@ -59,7 +59,7 @@ define void @test3(i32 %i) { br label %Loop Loop: ; Should not promote this to a register - %x = volatile load i32* @X + %x = load volatile i32* @X %x2 = add i32 %x, 1 store i32 %x2, i32* @X br i1 true, label %Out, label %Loop @@ -133,7 +133,7 @@ Loop: ; preds = %Loop, %0 %x2 = add i32 %x, 1 ; <i32> [#uses=1] store i32 %x2, i32* @X - volatile store i32* @X, i32** %P2 + store volatile i32* @X, i32** %P2 %Next = add i32 %j, 1 ; <i32> [#uses=2] %cond = icmp eq i32 %Next, 0 ; <i1> [#uses=1] diff --git a/test/Transforms/LICM/speculate.ll b/test/Transforms/LICM/speculate.ll new file mode 100644 index 000000000000..507b193e6b1c --- /dev/null +++ b/test/Transforms/LICM/speculate.ll @@ -0,0 +1,167 @@ +; RUN: opt -S -licm < %s | FileCheck %s + +; UDiv is safe to speculate if the denominator is known non-zero. + +; CHECK: @safe_udiv +; CHECK: %div = udiv i64 %x, %or +; CHECK-NEXT: br label %for.body + +define void @safe_udiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { +entry: + %or = or i64 %m, 1 + br label %for.body + +for.body: ; preds = %entry, %for.inc + %i.02 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %p, i64 %i.02 + %0 = load i32* %arrayidx, align 4 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %for.inc, label %if.then + +if.then: ; preds = %for.body + %div = udiv i64 %x, %or + %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 + store i64 %div, i64* %arrayidx1, align 8 + br label %for.inc + +for.inc: ; preds = %if.then, %for.body + %inc = add i64 %i.02, 1 + %cmp = icmp slt i64 %inc, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.inc, %entry + ret void +} + +; UDiv is unsafe to speculate if the denominator is not known non-zero. + +; CHECK: @unsafe_udiv +; CHECK-NOT: udiv +; CHECK: for.body: + +define void @unsafe_udiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { +entry: + br label %for.body + +for.body: ; preds = %entry, %for.inc + %i.02 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %p, i64 %i.02 + %0 = load i32* %arrayidx, align 4 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %for.inc, label %if.then + +if.then: ; preds = %for.body + %div = udiv i64 %x, %m + %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 + store i64 %div, i64* %arrayidx1, align 8 + br label %for.inc + +for.inc: ; preds = %if.then, %for.body + %inc = add i64 %i.02, 1 + %cmp = icmp slt i64 %inc, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.inc, %entry + ret void +} + +; SDiv is safe to speculate if the denominator is known non-zero and +; known to have at least one zero bit. + +; CHECK: @safe_sdiv +; CHECK: %div = sdiv i64 %x, %or +; CHECK-NEXT: br label %for.body + +define void @safe_sdiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { +entry: + %and = and i64 %m, -3 + %or = or i64 %and, 1 + br label %for.body + +for.body: ; preds = %entry, %for.inc + %i.02 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %p, i64 %i.02 + %0 = load i32* %arrayidx, align 4 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %for.inc, label %if.then + +if.then: ; preds = %for.body + %div = sdiv i64 %x, %or + %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 + store i64 %div, i64* %arrayidx1, align 8 + br label %for.inc + +for.inc: ; preds = %if.then, %for.body + %inc = add i64 %i.02, 1 + %cmp = icmp slt i64 %inc, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.inc, %entry + ret void +} + +; SDiv is unsafe to speculate if the denominator is not known non-zero. + +; CHECK: @unsafe_sdiv_a +; CHECK-NOT: sdiv +; CHECK: for.body: + +define void @unsafe_sdiv_a(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { +entry: + %or = or i64 %m, 1 + br label %for.body + +for.body: ; preds = %entry, %for.inc + %i.02 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %p, i64 %i.02 + %0 = load i32* %arrayidx, align 4 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %for.inc, label %if.then + +if.then: ; preds = %for.body + %div = sdiv i64 %x, %or + %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 + store i64 %div, i64* %arrayidx1, align 8 + br label %for.inc + +for.inc: ; preds = %if.then, %for.body + %inc = add i64 %i.02, 1 + %cmp = icmp slt i64 %inc, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.inc, %entry + ret void +} + +; SDiv is unsafe to speculate if the denominator is not known to have a zero bit. + +; CHECK: @unsafe_sdiv_b +; CHECK-NOT: sdiv +; CHECK: for.body: + +define void @unsafe_sdiv_b(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { +entry: + %and = and i64 %m, -3 + br label %for.body + +for.body: ; preds = %entry, %for.inc + %i.02 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %p, i64 %i.02 + %0 = load i32* %arrayidx, align 4 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %for.inc, label %if.then + +if.then: ; preds = %for.body + %div = sdiv i64 %x, %and + %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 + store i64 %div, i64* %arrayidx1, align 8 + br label %for.inc + +for.inc: ; preds = %if.then, %for.body + %inc = add i64 %i.02, 1 + %cmp = icmp slt i64 %inc, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.inc, %entry + ret void +} |