summaryrefslogtreecommitdiffstats
path: root/meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch')
-rw-r--r--meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch94
1 files changed, 94 insertions, 0 deletions
diff --git a/meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch b/meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch
new file mode 100644
index 0000000000..bcf30ffb56
--- /dev/null
+++ b/meta/packages/gcc/gcc-4.3.1/debian/pr33148.dpatch
@@ -0,0 +1,94 @@
1#! /bin/sh -e
2
3# DP: Fix (neg (lt X 0)) optimization (PR rtl-optimization/33148)
4
5dir=
6if [ $# -eq 3 -a "$2" = '-d' ]; then
7 pdir="-d $3"
8 dir="$3/"
9elif [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12fi
13case "$1" in
14 -patch)
15 patch $pdir -f --no-backup-if-mismatch -p0 < $0
16 ;;
17 -unpatch)
18 patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
19 ;;
20 *)
21 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
22 exit 1
23esac
24exit 0
25
26
27From: Jakub Jelinek <jakub@redhat.com>
28Sender: gcc-patches-owner@gcc.gnu.org
29To: gcc-patches@gcc.gnu.org
30Subject: [PATCH] Fix (neg (lt X 0)) optimization (PR rtl-optimization/33148)
31Date: Mon, 27 Aug 2007 07:22:44 -0400
32
33Hi!
34
35PR25600 change introduced an optimization of (neg (lt x 0)) to
36(ashirtrt x C), but it is not checking whether x's mode is suitable
37for it. As it checks that op1 is const0_rtx, I believe MODE_FLOAT
38or VECTOR_MODE_P modes are not a problem, CC modes can certainly appear
39in LT's first operand with second operand const0_rtx.
40So, when we optimize
41(neg:DI (lt:DI (reg:CC ...) (const_int 0)))
42we create something like
43(sign_extend:DI (ashirtrt:CC (reg:CC ...) (const_int 31)))
44which is IMHO invalid RTL, ashirtrt is documented on fixed point modes
45only (guess vector modes aren't listed just by omission) and so is
46sign_extend.
47
48Ok for 4.2/trunk?
49
502007-08-27 Jakub Jelinek <jakub@redhat.com>
51
52 PR rtl-optimization/33148
53 * simplify-rtx.c (simplify_unary_operation_1): Only optimize
54 (neg (lt X 0)) if X has scalar int mode.
55
56 * gcc.c-torture/compile/20070827-1.c: New test.
57
58--- gcc/simplify-rtx.c.jj 2007-08-27 10:15:33.000000000 +0200
59+++ gcc/simplify-rtx.c 2007-08-27 12:12:51.000000000 +0200
60@@ -583,7 +583,8 @@ simplify_unary_operation_1 (enum rtx_cod
61 /* (neg (lt x 0)) is (ashiftrt X C) if STORE_FLAG_VALUE is 1. */
62 /* (neg (lt x 0)) is (lshiftrt X C) if STORE_FLAG_VALUE is -1. */
63 if (GET_CODE (op) == LT
64- && XEXP (op, 1) == const0_rtx)
65+ && XEXP (op, 1) == const0_rtx
66+ && SCALAR_INT_MODE_P (GET_MODE (XEXP (op, 0))))
67 {
68 enum machine_mode inner = GET_MODE (XEXP (op, 0));
69 int isize = GET_MODE_BITSIZE (inner);
70--- gcc/testsuite/gcc.c-torture/compile/20070827-1.c.jj 2007-08-27 12:17:20.000000000 +0200
71+++ gcc/testsuite/gcc.c-torture/compile/20070827-1.c 2007-08-27 12:15:45.000000000 +0200
72@@ -0,0 +1,20 @@
73+/* PR rtl-optimization/33148 */
74+
75+int
76+foo (unsigned int *p, int *q, unsigned int w, unsigned int b)
77+{
78+ unsigned int i;
79+ int mask;
80+
81+ if (q[0] < q[1])
82+ mask = 0xff;
83+ else
84+ mask = 0;
85+
86+ for (i = 0; 8 * i < w; i++)
87+ {
88+ b ^= mask;
89+ *p++ = b;
90+ }
91+ return 0;
92+}
93
94 Jakub