summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2015-11-03 22:40:40 +0000
committerDerek Schuff <dschuff@google.com>2015-11-03 22:40:40 +0000
commit6b5c6da7603a6ddab37d93828b20141cd410c3da (patch)
tree4962600ebdef32b29a271eccd3663cbbb5c4e63e /llvm/test/CodeGen
parent0644900004343cd0eb094eba97a3f2edf61a1cd5 (diff)
downloadbcm5719-llvm-6b5c6da7603a6ddab37d93828b20141cd410c3da.tar.gz
bcm5719-llvm-6b5c6da7603a6ddab37d93828b20141cd410c3da.zip
[WebAssembly] Support wasm select operator
Summary: Add support for wasm's select operator, and lower LLVM's select DAG node to it. Reviewers: sunfish Subscribers: dschuff, llvm-commits, jfb Differential Revision: http://reviews.llvm.org/D14295 llvm-svn: 252002
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/WebAssembly/select.ll63
1 files changed, 63 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/select.ll b/llvm/test/CodeGen/WebAssembly/select.ll
new file mode 100644
index 00000000000..361101abfc2
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/select.ll
@@ -0,0 +1,63 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -fast-isel | FileCheck %s
+
+; Test that wasm select instruction is selected from LLVM select instruction.
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+;; CHECK-LABEL: select_i32:
+;; CHECK: get_local 1
+;; CHECK: set_local [[LOCAL_B:[0-9]]]
+;; CHECK: get_local 0
+;; CHECK: set_local [[LOCAL_A:[0-9]]]
+;; CHECK: i32.eq (get_local 5), (get_local 6)
+;; CHECK: set_local 7, pop
+;; CHECK: i32.select (get_local 7), (get_local [[LOCAL_A]]), (get_local [[LOCAL_B]])
+define i32 @select_i32(i32 %a, i32 %b, i32 %cond) {
+ %cc = icmp eq i32 %cond, 0
+ %result = select i1 %cc, i32 %a, i32 %b
+ ret i32 %result
+}
+
+;; CHECK-LABEL: select_i64:
+;; CHECK: get_local 1
+;; CHECK: set_local [[LOCAL_B:[0-9]]]
+;; CHECK: get_local 0
+;; CHECK: set_local [[LOCAL_A:[0-9]]]
+;; CHECK: i32.eq (get_local 5), (get_local 6)
+;; CHECK: set_local 7, pop
+;; CHECK: i64.select (get_local 7), (get_local [[LOCAL_A]]), (get_local [[LOCAL_B]])
+define i64 @select_i64(i64 %a, i64 %b, i32 %cond) {
+ %cc = icmp eq i32 %cond, 0
+ %result = select i1 %cc, i64 %a, i64 %b
+ ret i64 %result
+}
+
+;; CHECK-LABEL: select_f32:
+;; CHECK: get_local 1
+;; CHECK: set_local [[LOCAL_B:[0-9]]]
+;; CHECK: get_local 0
+;; CHECK: set_local [[LOCAL_A:[0-9]]]
+;; CHECK: i32.eq (get_local 5), (get_local 6)
+;; CHECK: set_local 7, pop
+;; CHECK: f32.select (get_local 7), (get_local [[LOCAL_A]]), (get_local [[LOCAL_B]])
+define float @select_f32(float %a, float %b, i32 %cond) {
+ %cc = icmp eq i32 %cond, 0
+ %result = select i1 %cc, float %a, float %b
+ ret float %result
+}
+
+;; CHECK-LABEL: select_f64:
+;; CHECK: get_local 1
+;; CHECK: set_local [[LOCAL_B:[0-9]]]
+;; CHECK: get_local 0
+;; CHECK: set_local [[LOCAL_A:[0-9]]]
+;; CHECK: i32.eq (get_local 5), (get_local 6)
+;; CHECK: set_local 7, pop
+;; CHECK: f64.select (get_local 7), (get_local [[LOCAL_A]]), (get_local [[LOCAL_B]])
+define double @select_f64(double %a, double %b, i32 %cond) {
+ %cc = icmp eq i32 %cond, 0
+ %result = select i1 %cc, double %a, double %b
+ ret double %result
+}
OpenPOWER on IntegriCloud