summaryrefslogtreecommitdiffstats
path: root/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch')
-rw-r--r--toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch134
1 files changed, 134 insertions, 0 deletions
diff --git a/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch
new file mode 100644
index 0000000000..59bf01cc56
--- /dev/null
+++ b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99502.patch
@@ -0,0 +1,134 @@
12011-04-26 Chung-Lin Tang <cltang@codesourcery.com>
2
3 Backport from mainline:
4
5 2011-03-21 Chung-Lin Tang <cltang@codesourcery.com>
6
7 gcc/
8 * simplify-rtx.c (simplify_binary_operation_1): Handle
9 (xor (and A B) C) case when B and C are both constants.
10
11 gcc/testsuite/
12 * gcc.target/arm/xor-and.c: New.
13
14 2011-03-18 Chung-Lin Tang <cltang@codesourcery.com>
15
16 gcc/
17 * combine.c (try_combine): Do simplification only call of
18 subst() on i2 even when i1 is present. Update comments.
19
20 gcc/testsuite/
21 * gcc.target/arm/unsigned-extend-1.c: New.
22
23=== modified file 'gcc/combine.c'
24--- old/gcc/combine.c 2011-01-06 11:02:44 +0000
25+++ new/gcc/combine.c 2011-04-14 13:58:12 +0000
26@@ -2939,7 +2939,7 @@
27 /* It is possible that the source of I2 or I1 may be performing
28 an unneeded operation, such as a ZERO_EXTEND of something
29 that is known to have the high part zero. Handle that case
30- by letting subst look at the innermost one of them.
31+ by letting subst look at the inner insns.
32
33 Another way to do this would be to have a function that tries
34 to simplify a single insn instead of merging two or more
35@@ -2964,11 +2964,9 @@
36 subst_low_luid = DF_INSN_LUID (i1);
37 i1src = subst (i1src, pc_rtx, pc_rtx, 0, 0, 0);
38 }
39- else
40- {
41- subst_low_luid = DF_INSN_LUID (i2);
42- i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0, 0);
43- }
44+
45+ subst_low_luid = DF_INSN_LUID (i2);
46+ i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0, 0);
47 }
48
49 n_occurrences = 0; /* `subst' counts here */
50
51=== modified file 'gcc/simplify-rtx.c'
52--- old/gcc/simplify-rtx.c 2010-06-25 20:11:56 +0000
53+++ new/gcc/simplify-rtx.c 2011-04-14 13:58:12 +0000
54@@ -2413,6 +2413,46 @@
55 XEXP (op0, 1), mode),
56 op1);
57
58+ /* Given (xor (and A B) C), using P^Q == (~P&Q) | (~Q&P),
59+ we can transform like this:
60+ (A&B)^C == ~(A&B)&C | ~C&(A&B)
61+ == (~A|~B)&C | ~C&(A&B) * DeMorgan's Law
62+ == ~A&C | ~B&C | A&(~C&B) * Distribute and re-order
63+ Attempt a few simplifications when B and C are both constants. */
64+ if (GET_CODE (op0) == AND
65+ && CONST_INT_P (op1)
66+ && CONST_INT_P (XEXP (op0, 1)))
67+ {
68+ rtx a = XEXP (op0, 0);
69+ rtx b = XEXP (op0, 1);
70+ rtx c = op1;
71+ HOST_WIDE_INT bval = INTVAL (b);
72+ HOST_WIDE_INT cval = INTVAL (c);
73+
74+ rtx na_c
75+ = simplify_binary_operation (AND, mode,
76+ simplify_gen_unary (NOT, mode, a, mode),
77+ c);
78+ if ((~cval & bval) == 0)
79+ {
80+ /* Try to simplify ~A&C | ~B&C. */
81+ if (na_c != NULL_RTX)
82+ return simplify_gen_binary (IOR, mode, na_c,
83+ GEN_INT (~bval & cval));
84+ }
85+ else
86+ {
87+ /* If ~A&C is zero, simplify A&(~C&B) | ~B&C. */
88+ if (na_c == const0_rtx)
89+ {
90+ rtx a_nc_b = simplify_gen_binary (AND, mode, a,
91+ GEN_INT (~cval & bval));
92+ return simplify_gen_binary (IOR, mode, a_nc_b,
93+ GEN_INT (~bval & cval));
94+ }
95+ }
96+ }
97+
98 /* (xor (comparison foo bar) (const_int 1)) can become the reversed
99 comparison if STORE_FLAG_VALUE is 1. */
100 if (STORE_FLAG_VALUE == 1
101
102=== added file 'gcc/testsuite/gcc.target/arm/unsigned-extend-1.c'
103--- old/gcc/testsuite/gcc.target/arm/unsigned-extend-1.c 1970-01-01 00:00:00 +0000
104+++ new/gcc/testsuite/gcc.target/arm/unsigned-extend-1.c 2011-04-14 13:58:12 +0000
105@@ -0,0 +1,9 @@
106+/* { dg-do compile } */
107+/* { dg-options "-O2 -march=armv6" } */
108+
109+unsigned char foo (unsigned char c)
110+{
111+ return (c >= '0') && (c <= '9');
112+}
113+
114+/* { dg-final { scan-assembler-not "uxtb" } } */
115
116=== added file 'gcc/testsuite/gcc.target/arm/xor-and.c'
117--- old/gcc/testsuite/gcc.target/arm/xor-and.c 1970-01-01 00:00:00 +0000
118+++ new/gcc/testsuite/gcc.target/arm/xor-and.c 2011-04-14 13:58:12 +0000
119@@ -0,0 +1,14 @@
120+/* { dg-do compile } */
121+/* { dg-options "-O -march=armv6" } */
122+
123+unsigned short foo (unsigned short x)
124+{
125+ x ^= 0x4002;
126+ x >>= 1;
127+ x |= 0x8000;
128+ return x;
129+}
130+
131+/* { dg-final { scan-assembler "orr" } } */
132+/* { dg-final { scan-assembler-not "mvn" } } */
133+/* { dg-final { scan-assembler-not "uxth" } } */
134