summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2013-07-01 19:42:46 +0000
committerCameron Zwarich <zwarich@apple.com>2013-07-01 19:42:46 +0000
commit03fae50cfa5631349fbd47f4c232fc78f5b3b8af (patch)
treefee337ff247891746df625b2f783b3ff5b792b74 /test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll
parentb5f7b0f9780cd1bc6f948b194adfc57176d41711 (diff)
downloadllvm-03fae50cfa5631349fbd47f4c232fc78f5b3b8af.tar.gz
llvm-03fae50cfa5631349fbd47f4c232fc78f5b3b8af.tar.bz2
llvm-03fae50cfa5631349fbd47f4c232fc78f5b3b8af.tar.xz
Fix PR16508.
When phis get lowered, destination copies are inserted using an iterator that is determined once for all phis in the block, which BuildMI interprets as a request to insert an instruction directly before the iterator. In the case of a cyclic phi, source copies may also be inserted directly before this iterator, which can cause source copies to be inserted before destination copies. The fix is to keep an iterator to the last phi and then advance it while lowering each phi in order to insert destination copies directly after the phis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll')
-rw-r--r--test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll b/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll
new file mode 100644
index 0000000000..635062b831
--- /dev/null
+++ b/test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll
@@ -0,0 +1,28 @@
+; RUN: llc < %s -verify-machineinstrs | FileCheck %s
+
+target 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-f128:128:128-v128:128:128-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+@g_51 = external global [8 x i32], align 4
+
+; CHECK: func_7
+
+; Function Attrs: nounwind
+define fastcc void @func_7() #0 {
+entry:
+ %arrayidx638 = getelementptr inbounds [3 x [1 x i32]]* undef, i64 0, i64 1, i64 0
+ br i1 undef, label %for.cond940, label %if.end1018
+
+for.cond940: ; preds = %for.cond940, %if.else876
+ %l_655.1 = phi i32* [ getelementptr inbounds ([8 x i32]* @g_51, i64 0, i64 6), %entry ], [ %l_654.0, %for.cond940 ]
+ %l_654.0 = phi i32* [ null, %entry ], [ %arrayidx638, %for.cond940 ]
+ %exitcond = icmp eq i32 undef, 20
+ br i1 %exitcond, label %if.end1018, label %for.cond940
+
+if.end1018: ; preds = %for.end957, %for.end834
+ %l_655.3.ph33 = phi i32* [ %l_655.1, %for.cond940 ], [ getelementptr inbounds ([8 x i32]* @g_51, i64 0, i64 6), %entry ]
+ store i32 0, i32* %l_655.3.ph33, align 4
+ ret void
+}
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }