NAKAMURA Takumi | a7246da | 2013-01-22 01:51:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | FileCheck %s |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 2 | // CHECK-LABEL: define i32 @f0 |
NAKAMURA Takumi | a7246da | 2013-01-22 01:51:59 +0000 | [diff] [blame] | 3 | // CHECK: ret i32 1 |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 4 | // CHECK-LABEL: define i32 @f1 |
NAKAMURA Takumi | a7246da | 2013-01-22 01:51:59 +0000 | [diff] [blame] | 5 | // CHECK: ret i32 1 |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 6 | // CHECK-LABEL: define i32 @f2 |
NAKAMURA Takumi | a7246da | 2013-01-22 01:51:59 +0000 | [diff] [blame] | 7 | // CHECK: ret i32 1 |
Daniel Dunbar | 8c6f57c | 2008-08-06 02:00:38 +0000 | [diff] [blame] | 8 | // <rdr://6115726> |
| 9 | |
| 10 | int f0() { |
| 11 | int x; |
| 12 | unsigned short n = 1; |
| 13 | int *a = &x; |
| 14 | int *b = &x; |
| 15 | a = a - n; |
| 16 | b -= n; |
| 17 | return a == b; |
| 18 | } |
| 19 | |
| 20 | int f1(int *a) { |
Sebastian Redl | f0d960a | 2008-11-12 00:18:32 +0000 | [diff] [blame] | 21 | long b = a - (int*) 1; |
Daniel Dunbar | 8c6f57c | 2008-08-06 02:00:38 +0000 | [diff] [blame] | 22 | a -= (int*) 1; |
Sebastian Redl | f0d960a | 2008-11-12 00:18:32 +0000 | [diff] [blame] | 23 | return b == (long) a; |
Daniel Dunbar | 8c6f57c | 2008-08-06 02:00:38 +0000 | [diff] [blame] | 24 | } |
| 25 | |
Sebastian Redl | f0d960a | 2008-11-12 00:18:32 +0000 | [diff] [blame] | 26 | int f2(long n) { |
Daniel Dunbar | 8c6f57c | 2008-08-06 02:00:38 +0000 | [diff] [blame] | 27 | int *b = n + (int*) 1; |
| 28 | n += (int*) 1; |
| 29 | return b == (int*) n; |
| 30 | } |
| 31 | |