]> git.pld-linux.org Git - packages/gcc.git/blame - gcc32-fold-const-associate.patch
- added gcc32-bison_expect.patch
[packages/gcc.git] / gcc32-fold-const-associate.patch
CommitLineData
5384b728 12002-08-05 Jakub Jelinek <jakub@redhat.com>
2
3 * fold-const.c (associate_trees): Only optimize NEGATE_EXPR in one
4 of the operands into MINUS_EXPR if code is PLUS_EXPR.
5
6 * gcc.c-torture/execute/20020805-1.c: New test.
7
8--- gcc/testsuite/gcc.c-torture/execute/20020805-1.c.jj 2002-08-05 18:27:42.000000000 +0200
9+++ gcc/testsuite/gcc.c-torture/execute/20020805-1.c 2002-08-05 18:26:42.000000000 +0200
10@@ -0,0 +1,21 @@
11+/* This testcase was miscompiled on IA-32, because fold-const
12+ assumed associate_trees is always done on PLUS_EXPR. */
13+
14+extern void abort (void);
15+extern void exit (int);
16+
17+void check (unsigned int m)
18+{
19+ if (m != (unsigned int) -1)
20+ abort ();
21+}
22+
23+unsigned int n = 1;
24+
25+int main (void)
26+{
27+ unsigned int m;
28+ m = (1 | (2 - n)) | (-n);
29+ check (m);
30+ exit (0);
31+}
32--- gcc/fold-const.c.jj 2002-08-05 18:16:25.000000000 +0200
33+++ gcc/fold-const.c 2002-08-05 18:16:25.000000000 +0200
34@@ -1500,14 +1500,16 @@ associate_trees (t1, t2, code, type)
35 if (TREE_CODE (t1) == code || TREE_CODE (t2) == code
36 || TREE_CODE (t1) == MINUS_EXPR || TREE_CODE (t2) == MINUS_EXPR)
37 {
38- if (TREE_CODE (t1) == NEGATE_EXPR)
39- return build (MINUS_EXPR, type, convert (type, t2),
40- convert (type, TREE_OPERAND (t1, 0)));
41- else if (TREE_CODE (t2) == NEGATE_EXPR)
42- return build (MINUS_EXPR, type, convert (type, t1),
43- convert (type, TREE_OPERAND (t2, 0)));
44- else
45- return build (code, type, convert (type, t1), convert (type, t2));
46+ if (code == PLUS_EXPR)
47+ {
48+ if (TREE_CODE (t1) == NEGATE_EXPR)
49+ return build (MINUS_EXPR, type, convert (type, t2),
50+ convert (type, TREE_OPERAND (t1, 0)));
51+ else if (TREE_CODE (t2) == NEGATE_EXPR)
52+ return build (MINUS_EXPR, type, convert (type, t1),
53+ convert (type, TREE_OPERAND (t2, 0)));
54+ }
55+ return build (code, type, convert (type, t1), convert (type, t2));
56 }
57
58 return fold (build (code, type, convert (type, t1), convert (type, t2)));
This page took 0.093472 seconds and 4 git commands to generate.