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

Unified Diff: tests_lit/llvm2ice_tests/switch-opt.ll

Issue 701673002: Subzero: Implement switch lowering for i64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove RUIN line Created 6 years, 1 month 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/IceTargetLoweringX8632.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/switch-opt.ll
diff --git a/tests_lit/llvm2ice_tests/switch-opt.ll b/tests_lit/llvm2ice_tests/switch-opt.ll
index 6b9616f65ff56c09aadd59e850db1b9c26581ffc..53a6b2785c7c0e0b82713752696c8313c08dc5a5 100644
--- a/tests_lit/llvm2ice_tests/switch-opt.ll
+++ b/tests_lit/llvm2ice_tests/switch-opt.ll
@@ -2,7 +2,9 @@
; same label which also results in phi instructions with multiple
; entries for the same incoming edge.
-; RUN: %p2i -i %s -a --verbose inst | FileCheck %s
+; RUN: %p2i -i %s --args -O2 --verbose none \
+; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \
+; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s
; RUN: %p2i -i %s -a --verbose none | FileCheck --check-prefix=ERRORS %s
; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s
@@ -51,6 +53,68 @@ sw.default:
; CHECK-LABEL: testSwitchImm
; CHECK-NOT: cmp {{[0-9]*}},
+; Test for correct 64-bit lowering.
+define internal i32 @testSwitch64(i64 %a) {
+entry:
+ switch i64 %a, label %sw.default [
+ i64 123, label %return
+ i64 234, label %sw.bb1
+ i64 345, label %sw.bb2
+ i64 78187493520, label %sw.bb3
+ ]
+
+sw.bb1: ; preds = %entry
+ br label %return
+
+sw.bb2: ; preds = %entry
+ br label %return
+
+sw.bb3: ; preds = %entry
+ br label %return
+
+sw.default: ; preds = %entry
+ br label %return
+
+return: ; preds = %sw.default, %sw.bb3, %sw.bb2, %sw.bb1, %entry
+ %retval.0 = phi i32 [ 5, %sw.default ], [ 4, %sw.bb3 ], [ 3, %sw.bb2 ], [ 2, %sw.bb1 ], [ 1, %entry ]
+ ret i32 %retval.0
+}
+; CHECK-LABEL: testSwitch64
+; CHECK: cmp {{.*}}, 123
+; CHECK-NEXT: jne
+; CHECK-NEXT: cmp {{.*}}, 0
+; CHECK-NEXT: je
+; CHECK: cmp {{.*}}, 234
+; CHECK-NEXT: jne
+; CHECK-NEXT: cmp {{.*}}, 0
+; CHECK-NEXT: je
+; CHECK: cmp {{.*}}, 345
+; CHECK-NEXT: jne
+; CHECK-NEXT: cmp {{.*}}, 0
+; CHECK-NEXT: je
+; CHECK: cmp {{.*}}, 878082192
+; CHECK-NEXT: jne
+; CHECK-NEXT: cmp {{.*}}, 18
+; CHECK-NEXT: je
+
+; Similar to testSwitchImm, make sure proper addressing modes are
+; used. In reality, this is tested by running the output through the
+; assembler.
+define i32 @testSwitchImm64() {
+entry:
+ switch i64 10, label %sw.default [
+ i64 1, label %sw.default
+ ]
+
+sw.default:
+ ret i32 20
+}
+; CHECK-LABEL: testSwitchImm64
+; CHECK: cmp {{.*}}, 1
+; CHECK-NEXT: jne
+; CHECK-NEXT: cmp {{.*}}, 0
+; CHECK-NEXT: je
+
; CHECK-NOT: ICE translation error
; ERRORS-NOT: ICE translation error
; DUMP-NOT: SZ
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698