From 152f18f671fb787eda1b803e956725095fd7ffa3 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 9 Oct 2007 20:51:27 +0000 Subject: Recognize while(1) and avoid extra blocks. llvm-svn: 42811 --- clang/test/CodeGen/whilestmt.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 clang/test/CodeGen/whilestmt.c (limited to 'clang/test/CodeGen/whilestmt.c') diff --git a/clang/test/CodeGen/whilestmt.c b/clang/test/CodeGen/whilestmt.c new file mode 100644 index 00000000000..8ded265d0c0 --- /dev/null +++ b/clang/test/CodeGen/whilestmt.c @@ -0,0 +1,62 @@ +// RUN: clang %s -emit-llvm + +int bar(); +int foo() { + int i; + i = 1 + 2; + while(1) { + i = bar(); + i = bar(); + }; + return i; +} + + +int foo1() { + int i; + i = 1 + 2; + while(1) { + i = bar(); + if (i == 42) + break; + i = bar(); + }; + return i; +} + + +int foo2() { + int i; + i = 1 + 2; + while(1) { + i = bar(); + if (i == 42) + continue; + i = bar(); + }; + return i; +} + + +int foo3() { + int i; + i = 1 + 2; + while(1) { + i = bar(); + if (i == 42) + break; + }; + return i; +} + + +int foo4() { + int i; + i = 1 + 2; + while(1) { + i = bar(); + if (i == 42) + continue; + }; + return i; +} -- cgit v1.2.3