diff options
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/immediate_merging.ll | 82 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/remat-invalid-liveness.ll | 85 |
2 files changed, 82 insertions, 85 deletions
diff --git a/llvm/test/CodeGen/X86/immediate_merging.ll b/llvm/test/CodeGen/X86/immediate_merging.ll new file mode 100644 index 00000000000..8aef9c279b3 --- /dev/null +++ b/llvm/test/CodeGen/X86/immediate_merging.ll @@ -0,0 +1,82 @@ +; RUN: llc -o - -mtriple=i386-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s + +@a = common global i32 0, align 4 +@b = common global i32 0, align 4 +@c = common global i32 0, align 4 +@e = common global i32 0, align 4 +@x = common global i32 0, align 4 +@f = common global i32 0, align 4 +@h = common global i32 0, align 4 +@i = common global i32 0, align 4 + +; Test -Os to make sure immediates with multiple users don't get pulled in to +; instructions. +define i32 @foo() optsize { +; CHECK-LABEL: foo: +; CHECK: movl $1234, [[R1:%[a-z]+]] +; CHECK-NOT: movl $1234, a +; CHECK-NOT: movl $1234, b +; CHECK-NOT: movl $12, c +; CHECK-NOT: cmpl $12, e +; CHECK: movl [[R1]], a +; CHECK: movl [[R1]], b + +entry: + store i32 1234, i32* @a + store i32 1234, i32* @b + store i32 12, i32* @c + %0 = load i32, i32* @e + %cmp = icmp eq i32 %0, 12 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + store i32 1, i32* @x + br label %if.end + +; New block.. Make sure 1234 isn't live across basic blocks from before. +; CHECK: movl $1234, f +; CHECK: movl $555, [[R3:%[a-z]+]] +; CHECK-NOT: movl $555, h +; CHECK-NOT: addl $555, i +; CHECK: movl [[R3]], h +; CHECK: addl [[R3]], i + +if.end: ; preds = %if.then, %entry + store i32 1234, i32* @f + store i32 555, i32* @h + %1 = load i32, i32* @i + %add1 = add nsw i32 %1, 555 + store i32 %add1, i32* @i + ret i32 0 +} + +; Test -O2 to make sure that all immediates get pulled in to their users. +define i32 @foo2() { +; CHECK-LABEL: foo2: +; CHECK: movl $1234, a +; CHECK: movl $1234, b + +entry: + store i32 1234, i32* @a + store i32 1234, i32* @b + + ret i32 0 +} + +declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #1 + +@AA = common global [100 x i8] zeroinitializer, align 1 + +; memset gets lowered in DAG. Constant merging should hoist all the +; immediates used to store to the individual memory locations. Make +; sure we don't directly store the immediates. +define void @foomemset() optsize { +; CHECK-LABEL: foomemset: +; CHECK-NOT: movl ${{.*}}, AA +; CHECK: mov{{l|q}} %{{e|r}}ax, AA + +entry: + call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @AA, i32 0, i32 0), i8 33, i32 24, i32 1, i1 false) + ret void +} diff --git a/llvm/test/CodeGen/X86/remat-invalid-liveness.ll b/llvm/test/CodeGen/X86/remat-invalid-liveness.ll deleted file mode 100644 index c6b43b0dd3e..00000000000 --- a/llvm/test/CodeGen/X86/remat-invalid-liveness.ll +++ /dev/null @@ -1,85 +0,0 @@ -; RUN: llc %s -mcpu=core2 -o - | FileCheck %s -; This test was failing while tracking the liveness in the register scavenger -; during the branching folding pass. The allocation of the subregisters was -; incorrect. -; I.e., the faulty pattern looked like: -; CH = movb 64 -; ECX = movl 3 <- CH was killed here. -; CH = subb CH, ... -; -; This reduced test case triggers the crash before the fix, but does not -; strictly speaking check that the resulting code is correct. -; To check that the code is actually correct we would need to check the -; liveness of the produced code. -; -; Currently, we check that after ECX = movl 3, we do not have subb CH, -; whereas CH could have been redefine in between and that would have been -; totally fine. -; <rdar://problem/16582185> -target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" -target triple = "i386-apple-macosx10.9" - -%struct.A = type { %struct.B, %struct.C, %struct.D*, [1 x i8*] } -%struct.B = type { i32, [4 x i8] } -%struct.C = type { i128 } -%struct.D = type { {}*, [0 x i32] } -%union.E = type { i32 } - -; CHECK-LABEL: __XXX1: -; CHECK: movl $3, %ecx -; CHECK-NOT: subb %{{[a-z]+}}, %ch -; Function Attrs: nounwind optsize ssp -define fastcc void @__XXX1(%struct.A* %ht) #0 { -entry: - %const72 = bitcast i128 72 to i128 - %const3 = bitcast i128 3 to i128 - switch i32 undef, label %if.end196 [ - i32 1, label %sw.bb.i - i32 3, label %sw.bb2.i - ] - -sw.bb.i: ; preds = %entry - %call.i.i.i = tail call i32 undef(%struct.A* %ht, i8 zeroext 22, i32 undef, i32 0, %struct.D* undef) - %bf.load.i.i = load i128, i128* undef, align 4 - %bf.lshr.i.i = lshr i128 %bf.load.i.i, %const72 - %shl1.i.i = shl nuw nsw i128 %bf.lshr.i.i, 8 - %shl.i.i = trunc i128 %shl1.i.i to i32 - br i1 undef, label %cond.false10.i.i, label %__XXX2.exit.i.i - -__XXX2.exit.i.i: ; preds = %sw.bb.i - %extract11.i.i.i = lshr i128 %bf.load.i.i, %const3 - %extract.t12.i.i.i = trunc i128 %extract11.i.i.i to i32 - %bf.cast7.i.i.i = and i32 %extract.t12.i.i.i, 3 - %arrayidx.i.i.i = getelementptr inbounds %struct.A, %struct.A* %ht, i32 0, i32 3, i32 %bf.cast7.i.i.i - br label %cond.end12.i.i - -cond.false10.i.i: ; preds = %sw.bb.i - %arrayidx.i6.i.i = getelementptr inbounds %struct.A, %struct.A* %ht, i32 0, i32 3, i32 0 - br label %cond.end12.i.i - -cond.end12.i.i: ; preds = %cond.false10.i.i, %__XXX2.exit.i.i - %.sink.in.i.i = phi i8** [ %arrayidx.i.i.i, %__XXX2.exit.i.i ], [ %arrayidx.i6.i.i, %cond.false10.i.i ] - %.sink.i.i = load i8*, i8** %.sink.in.i.i, align 4 - %tmp = bitcast i8* %.sink.i.i to %union.E* - br i1 undef, label %for.body.i.i, label %if.end196 - -for.body.i.i: ; preds = %for.body.i.i, %cond.end12.i.i - %weak.i.i = getelementptr inbounds %union.E, %union.E* %tmp, i32 undef, i32 0 - %tmp1 = load i32, i32* %weak.i.i, align 4 - %cmp36.i.i = icmp ne i32 %tmp1, %shl.i.i - %or.cond = and i1 %cmp36.i.i, false - br i1 %or.cond, label %for.body.i.i, label %if.end196 - -sw.bb2.i: ; preds = %entry - %bf.lshr.i85.i = lshr i128 undef, %const72 - br i1 undef, label %if.end196, label %__XXX2.exit.i95.i - -__XXX2.exit.i95.i: ; preds = %sw.bb2.i - %extract11.i.i91.i = lshr i128 undef, %const3 - br label %if.end196 - -if.end196: ; preds = %__XXX2.exit.i95.i, %sw.bb2.i, %for.body.i.i, %cond.end12.i.i, %entry - ret void -} - -attributes #0 = { nounwind optsize ssp "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" } |

