]>
Commit | Line | Data |
---|---|---|
ed635824 MT |
1 | 2010-07-07 Jakub Jelinek <jakub@redhat.com> |
2 | ||
3 | * tree-sra.c (sra_build_assignment): Don't add BIT_XOR_EXPR/MINUS_EXPR | |
4 | of signbit if signbit is the most significant bit of utype already. | |
5 | ||
6 | * gcc.c-torture/execute/20100707-1.c: New test. | |
7 | ||
8 | --- gcc/tree-sra.c.jj 2010-05-13 13:08:52.000000000 +0200 | |
9 | +++ gcc/tree-sra.c 2010-07-06 19:50:09.000000000 +0200 | |
10 | @@ -2211,7 +2211,10 @@ sra_build_assignment (tree dst, tree src | |
11 | ||
12 | /* Perform sign extension, if required. | |
13 | ??? This should never be necessary. */ | |
14 | - if (!unsignedp) | |
15 | + if (!unsignedp | |
16 | + && (TREE_INT_CST_LOW (width) != TYPE_PRECISION (utype) | |
17 | + || (TREE_INT_CST_LOW (width) | |
18 | + != GET_MODE_BITSIZE (TYPE_MODE (utype))))) | |
19 | { | |
20 | tree signbit = int_const_binop (LSHIFT_EXPR, | |
21 | build_int_cst_wide (utype, 1, 0), | |
22 | --- gcc/testsuite/gcc.c-torture/execute/20100707-1.c 2010-05-27 15:41:40.446237053 +0200 | |
23 | +++ gcc/testsuite/gcc.c-torture/execute/20100707-1.c 2010-07-06 13:55:35.000000000 +0200 | |
24 | @@ -0,0 +1,50 @@ | |
25 | +struct S { int s; }; | |
26 | +struct T { int w; int h; }; | |
27 | +int vr; | |
28 | + | |
29 | +inline struct T | |
30 | +bar (const struct S * x) | |
31 | +{ | |
32 | + struct T t; | |
33 | + t.w = vr; | |
34 | + t.h = x->s; | |
35 | + return t; | |
36 | +} | |
37 | + | |
38 | +__attribute__ ((noinline)) | |
39 | +void foo (struct S * w, unsigned char *x, int y, int *z[2]) | |
40 | +{ | |
41 | + struct T t; | |
42 | + int i, j, k; | |
43 | + t = bar (w); | |
44 | + k = t.w + 2; | |
45 | + for (i = 0; i <= t.h; i++) | |
46 | + { | |
47 | + int *u = z[i > 0] + 1; | |
48 | + unsigned char *v; | |
49 | + int q = 0; | |
50 | + v = x + k * i + 1; | |
51 | + for (j = 0; j < t.w; j++) | |
52 | + { | |
53 | + int m = u[j]; | |
54 | + if (m > y && !q && v[j - k] != 2) | |
55 | + v[j] = 0; | |
56 | + } | |
57 | + } | |
58 | +} | |
59 | + | |
60 | +unsigned char b[64]; | |
61 | + | |
62 | +int | |
63 | +main (void) | |
64 | +{ | |
65 | + int v[32], *z[2]; | |
66 | + struct S s; | |
67 | + __builtin_memset (v, 0, sizeof (v)); | |
68 | + vr = 16; | |
69 | + s.s = 16; | |
70 | + z[0] = v; | |
71 | + z[1] = v; | |
72 | + foo (&s, b + 32, -1, z); | |
73 | + return 0; | |
74 | +} |