blob: 9fd8cfacecbf662aaa4113c42f67195b5b30940a [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts -S | grep "ret i32 2520"
Daniel Dunbar0ffb1252008-08-04 16:51:22 +00002
3static int foo(unsigned i) {
Chris Lattner6ebd79b2009-10-29 01:20:34 +00004 void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
Daniel Dunbar0ffb1252008-08-04 16:51:22 +00005 int res = 1;
6
7 goto *addrs[i];
8 L5: res *= 11;
9 L4: res *= 7;
10 L3: res *= 5;
11 L2: res *= 3;
12 L1: res *= 2;
13 return res;
14}
15
Chris Lattner6ebd79b2009-10-29 01:20:34 +000016static int foo2(unsigned i) {
17 static const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
18 int res = 1;
19
20 goto *addrs[i];
21L5: res *= 11;
22L4: res *= 7;
23L3: res *= 5;
24L2: res *= 3;
25L1: res *= 2;
26 return res;
27}
28
Chris Lattner7b8da892009-10-29 05:25:27 +000029int main() {
Chris Lattner6ebd79b2009-10-29 01:20:34 +000030 return foo(3)+foo2(4);
Daniel Dunbar0ffb1252008-08-04 16:51:22 +000031}