]> granicus.if.org Git - clang/commitdiff
CodeGen: Test that simple expressions are simplified at -O0
authorJustin Bogner <mail@justinbogner.com>
Mon, 4 Nov 2013 16:13:23 +0000 (16:13 +0000)
committerJustin Bogner <mail@justinbogner.com>
Mon, 4 Nov 2013 16:13:23 +0000 (16:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193995 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/branch-on-bool.c [new file with mode: 0644]

diff --git a/test/CodeGen/branch-on-bool.c b/test/CodeGen/branch-on-bool.c
new file mode 100644 (file)
index 0000000..78dae1b
--- /dev/null
@@ -0,0 +1,22 @@
+// RUN: %clang %s -O0 -emit-llvm -S -o - | FileCheck %s
+
+void foo();
+void bar();
+
+void fold_if(int a, int b) {
+  // CHECK: define {{.*}} @fold_if(
+  // CHECK-NOT: = phi
+  // CHECK: }
+  if (a && b)
+    foo();
+  else
+    bar();
+}
+
+void fold_for(int a, int b) {
+  // CHECK: define {{.*}} @fold_for(
+  // CHECK-NOT: = phi
+  // CHECK: }
+  for (int i = 0; a && i < b; ++i) foo();
+  for (int i = 0; a || i < b; ++i) bar();
+}