Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: tests_lit/llvm2ice_tests/phi.ll

Issue 560773002: Subzero: Fix Phi lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes, plus a new TODO Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/llvm2ice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests_lit/llvm2ice_tests/phi.ll
diff --git a/tests_lit/llvm2ice_tests/phi.ll b/tests_lit/llvm2ice_tests/phi.ll
new file mode 100644
index 0000000000000000000000000000000000000000..ae9606338cd4390c5c409e8e8b70af29a3b803e5
--- /dev/null
+++ b/tests_lit/llvm2ice_tests/phi.ll
@@ -0,0 +1,60 @@
+; This tests some of the subtleties of Phi lowering. In particular,
+; it tests that it does the right thing when it tries to enable
+; compare/branch fusing.
+
+; RUN: %llvm2ice -O2 --verbose none --no-phi-edge-split %s \
+; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \
+; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - | FileCheck %s
+; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN: | FileCheck --check-prefix=DUMP %s
+
+define internal i32 @testPhi1(i32 %arg) {
+entry:
+ %cmp1 = icmp sgt i32 %arg, 0
+ br i1 %cmp1, label %next, label %target
+next:
+ br label %target
+target:
+ %merge = phi i1 [ %cmp1, %entry ], [ false, %next ]
+ %result = zext i1 %merge to i32
+ ret i32 %result
+}
+; Test that compare/branch fusing does not happen, and Phi lowering is
+; put in the right place.
+; CHECK-LABEL: testPhi1
+; CHECK: cmp {{.*}}, 0
+; CHECK: mov {{.*}}, 1
+; CHECK: jg
+; CHECK: mov {{.*}}, 0
+; CHECK: mov [[PHI:.*]],
+; CHECK: cmp {{.*}}, 0
+; CHECK: jne
+; CHECK: :
+; CHECK: mov [[PHI]], 0
+; CHECK: :
+; CHECK: movzx {{.*}}, [[PHI]]
+
+define internal i32 @testPhi2(i32 %arg) {
+entry:
+ %cmp1 = icmp sgt i32 %arg, 0
+ br i1 %cmp1, label %next, label %target
+next:
+ br label %target
+target:
+ %merge = phi i32 [ 12345, %entry ], [ 54321, %next ]
+ ret i32 %merge
+}
+; Test that compare/branch fusing and Phi lowering happens as expected.
+; CHECK-LABEL: testPhi2
+; CHECK: mov {{.*}}, 12345
+; CHECK: cmp {{.*}}, 0
+; CHECK-NEXT: jg
+; CHECK: :
+; CHECK: mov [[PHI:.*]], 54321
+; CHECK: :
+; CHECK: mov {{.*}}, [[PHI]]
+
+; ERRORS-NOT: ICE translation error
+; DUMP-NOT: SZ
« no previous file with comments | « src/llvm2ice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698