OSDN Git Service

2010-05-02 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / badshift.c
1 /* PR rtl-optimization/20532 */
2
3 /* { dg-do run } */
4 /* { dg-options "" } */
5 /* { dg-options "-march=i386" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
6
7 /* We used to optimize the DImode shift-by-32 to zero because in combine
8    we turned:
9
10      (v << 31) + (v << 31)
11
12    into:
13
14      (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31)))
15
16    With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero.  */
17
18 unsigned long long int badshift(unsigned long long int v)
19 {
20         return v << 31 << 1;
21 }
22
23 extern void abort ();
24
25 int main() {
26   if (badshift (1) == 0)
27     abort ();
28   return 0;
29 }