summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-11-08 19:40:38 +0000
committerDan Gohman <dan433584@gmail.com>2016-11-08 19:40:38 +0000
commite81021a5cb3ece677b051a3175668e51a124f712 (patch)
tree66e808382fe45b00f02869143ec789b4b031158a /llvm/test
parent53a03a28c4e88816994deaec3a835458b8df35d2 (diff)
downloadbcm5719-llvm-e81021a5cb3ece677b051a3175668e51a124f712.tar.gz
bcm5719-llvm-e81021a5cb3ece677b051a3175668e51a124f712.zip
[WebAssembly] Convert stackified IMPLICIT_DEF into constant 0.
Since IMPLIFIT_DEF instructions are omitted in the output, when the output of an IMPLICIT_DEF instruction is stackified, the resulting register lacks an explicit push, leading to a push/pop mismatch. Fix this by converting such IMPLICIT_DEFs into CONST_I32 0 instructions so that they have explicit pushes. llvm-svn: 286274
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/WebAssembly/implicit-def.ll50
1 files changed, 50 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/implicit-def.ll b/llvm/test/CodeGen/WebAssembly/implicit-def.ll
new file mode 100644
index 00000000000..01ee171b449
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/implicit-def.ll
@@ -0,0 +1,50 @@
+; RUN: llc -o - %s | FileCheck %s
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; Test that stackified IMPLICIT_DEF instructions are converted into
+; CONST_I32 to provide an explicit push.
+
+; CHECK: br_if 2,
+; CHECK: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
+; CHECK-NEXT: return $pop[[L0]]{{$}}
+define i1 @f() {
+ %a = xor i1 0, 0
+ switch i1 %a, label %C [
+ i1 0, label %A
+ i1 1, label %B
+ ]
+
+A:
+ %b = xor i1 0, 0
+ br label %X
+
+B:
+ %c = xor i1 0, 0
+ br i1 %c, label %D, label %X
+
+C:
+ %d = icmp slt i32 0, 0
+ br i1 %d, label %G, label %F
+
+D:
+ %e = xor i1 0, 0
+ br i1 %e, label %E, label %X
+
+E:
+ %f = xor i1 0, 0
+ br label %X
+
+F:
+ %g = xor i1 0, 0
+ br label %G
+
+G:
+ %h = phi i1 [ undef, %C ], [ false, %F ]
+ br label %X
+
+X:
+ %i = phi i1 [ true, %A ], [ true, %B ], [ true, %D ], [ true, %E ], [ %h, %G ]
+ ret i1 %i
+}
+
OpenPOWER on IntegriCloud