Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts -S | grep "ret i32 2520" |
Daniel Dunbar | 0ffb125 | 2008-08-04 16:51:22 +0000 | [diff] [blame] | 2 | |
| 3 | static int foo(unsigned i) { |
Chris Lattner | 6ebd79b | 2009-10-29 01:20:34 +0000 | [diff] [blame] | 4 | void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 }; |
Daniel Dunbar | 0ffb125 | 2008-08-04 16:51:22 +0000 | [diff] [blame] | 5 | 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 Lattner | 6ebd79b | 2009-10-29 01:20:34 +0000 | [diff] [blame] | 16 | static int foo2(unsigned i) { |
| 17 | static const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 }; |
| 18 | int res = 1; |
| 19 | |
| 20 | goto *addrs[i]; |
| 21 | L5: res *= 11; |
| 22 | L4: res *= 7; |
| 23 | L3: res *= 5; |
| 24 | L2: res *= 3; |
| 25 | L1: res *= 2; |
| 26 | return res; |
| 27 | } |
| 28 | |
Chris Lattner | 7b8da89 | 2009-10-29 05:25:27 +0000 | [diff] [blame] | 29 | int main() { |
Chris Lattner | 6ebd79b | 2009-10-29 01:20:34 +0000 | [diff] [blame] | 30 | return foo(3)+foo2(4); |
Daniel Dunbar | 0ffb125 | 2008-08-04 16:51:22 +0000 | [diff] [blame] | 31 | } |