about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorDjzin <djzin@users.noreply.github.com>2017-11-13 23:24:30 +0000
committerDjzin <djzin@users.noreply.github.com>2017-11-14 06:33:39 +0000
commitc503fe113491500bac170c791e71cf02c45ab6e3 (patch)
tree04045dbf71910de3c31439530e7171c532906c25 /src/test/codegen
parentaed0c9c9c034eed04a9cfdc238e6c50696a308cc (diff)
downloadrust-c503fe113491500bac170c791e71cf02c45ab6e3.tar.gz
rust-c503fe113491500bac170c791e71cf02c45ab6e3.zip
add optimization codegen tests
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/match-optimizes-away.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/codegen/match-optimizes-away.rs b/src/test/codegen/match-optimizes-away.rs
new file mode 100644
index 00000000000..c0f2f64f82c
--- /dev/null
+++ b/src/test/codegen/match-optimizes-away.rs
@@ -0,0 +1,44 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// no-system-llvm
+// compile-flags: -O
+#![crate_type="lib"]
+
+pub enum Three { First, Second, Third }
+use Three::*;
+
+pub enum Four { First, Second, Third, Fourth }
+use Four::*;
+
+#[no_mangle]
+pub fn three_valued(x: Three) -> Three {
+    // CHECK-LABEL: @three_valued
+    // CHECK-NEXT: {{^.*:$}}
+    // CHECK-NEXT: ret i8 %0
+    match x {
+        First => First,
+        Second => Second,
+        Third => Third,
+    }
+}
+
+#[no_mangle]
+pub fn four_valued(x: Four) -> Four {
+    // CHECK-LABEL: @four_valued
+    // CHECK-NEXT: {{^.*:$}}
+    // CHECK-NEXT: ret i8 %0
+    match x {
+        First => First,
+        Second => Second,
+        Third => Third,
+        Fourth => Fourth,
+    }
+}