summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch')
-rw-r--r--recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch130
1 files changed, 130 insertions, 0 deletions
diff --git a/recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch b/recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch
new file mode 100644
index 0000000000..72a221b1d2
--- /dev/null
+++ b/recipes-devtools/gcc/gcc-4.5/gcc-linaro-fix-lp-653316.patch
@@ -0,0 +1,130 @@
12010-10-15 Chung-Lin Tang <cltang@codesourcery.com>
2
3 Backport from mainline:
4
5 2010-10-15 Chung-Lin Tang <cltang@codesourcery.com>
6
7 gcc/
8 * ifcvt.c (find_active_insn_before): New function.
9 (find_active_insn_after): New function.
10 (cond_exec_process_if_block): Use new functions to replace
11 prev_active_insn() and next_active_insn().
12
13 gcc/testsuite/
14 * gcc.dg/20101010-1.c: New testcase.
15
16=== modified file 'gcc/ifcvt.c'
17Index: gcc-4.5/gcc/ifcvt.c
18===================================================================
19--- gcc-4.5.orig/gcc/ifcvt.c
20+++ gcc-4.5/gcc/ifcvt.c
21@@ -88,6 +88,8 @@ static int count_bb_insns (const_basic_b
22 static bool cheap_bb_rtx_cost_p (const_basic_block, int);
23 static rtx first_active_insn (basic_block);
24 static rtx last_active_insn (basic_block, int);
25+static rtx find_active_insn_before (basic_block, rtx);
26+static rtx find_active_insn_after (basic_block, rtx);
27 static basic_block block_fallthru (basic_block);
28 static int cond_exec_process_insns (ce_if_block_t *, rtx, rtx, rtx, rtx, int);
29 static rtx cond_exec_get_condition (rtx);
30@@ -230,6 +232,48 @@ last_active_insn (basic_block bb, int sk
31 return insn;
32 }
33
34+/* Return the active insn before INSN inside basic block CURR_BB. */
35+
36+static rtx
37+find_active_insn_before (basic_block curr_bb, rtx insn)
38+{
39+ if (!insn || insn == BB_HEAD (curr_bb))
40+ return NULL_RTX;
41+
42+ while ((insn = PREV_INSN (insn)) != NULL_RTX)
43+ {
44+ if (NONJUMP_INSN_P (insn) || JUMP_P (insn) || CALL_P (insn))
45+ break;
46+
47+ /* No other active insn all the way to the start of the basic block. */
48+ if (insn == BB_HEAD (curr_bb))
49+ return NULL_RTX;
50+ }
51+
52+ return insn;
53+}
54+
55+/* Return the active insn after INSN inside basic block CURR_BB. */
56+
57+static rtx
58+find_active_insn_after (basic_block curr_bb, rtx insn)
59+{
60+ if (!insn || insn == BB_END (curr_bb))
61+ return NULL_RTX;
62+
63+ while ((insn = NEXT_INSN (insn)) != NULL_RTX)
64+ {
65+ if (NONJUMP_INSN_P (insn) || JUMP_P (insn) || CALL_P (insn))
66+ break;
67+
68+ /* No other active insn all the way to the end of the basic block. */
69+ if (insn == BB_END (curr_bb))
70+ return NULL_RTX;
71+ }
72+
73+ return insn;
74+}
75+
76 /* Return the basic block reached by falling though the basic block BB. */
77
78 static basic_block
79@@ -448,9 +492,9 @@ cond_exec_process_if_block (ce_if_block_
80 if (n_matching > 0)
81 {
82 if (then_end)
83- then_end = prev_active_insn (then_first_tail);
84+ then_end = find_active_insn_before (then_bb, then_first_tail);
85 if (else_end)
86- else_end = prev_active_insn (else_first_tail);
87+ else_end = find_active_insn_before (else_bb, else_first_tail);
88 n_insns -= 2 * n_matching;
89 }
90
91@@ -488,9 +532,9 @@ cond_exec_process_if_block (ce_if_block_
92 if (n_matching > 0)
93 {
94 if (then_start)
95- then_start = next_active_insn (then_last_head);
96+ then_start = find_active_insn_after (then_bb, then_last_head);
97 if (else_start)
98- else_start = next_active_insn (else_last_head);
99+ else_start = find_active_insn_after (else_bb, else_last_head);
100 n_insns -= 2 * n_matching;
101 }
102 }
103@@ -646,7 +690,7 @@ cond_exec_process_if_block (ce_if_block_
104 {
105 rtx from = then_first_tail;
106 if (!INSN_P (from))
107- from = next_active_insn (from);
108+ from = find_active_insn_after (then_bb, from);
109 delete_insn_chain (from, BB_END (then_bb), false);
110 }
111 if (else_last_head)
112Index: gcc-4.5/gcc/testsuite/gcc.dg/20101010-1.c
113===================================================================
114--- /dev/null
115+++ gcc-4.5/gcc/testsuite/gcc.dg/20101010-1.c
116@@ -0,0 +1,14 @@
117+/* { dg-do compile } */
118+/* { dg-options "-O2 -fno-crossjumping" } */
119+
120+int foo (void)
121+{
122+ int len;
123+ if (bar1 (&len))
124+ {
125+ char devpath [len];
126+ if (bar2 (devpath) == len)
127+ return len;
128+ }
129+ return -1;
130+}