Merge lp:~ams-codesourcery/gcc-linaro/lp641397-4.6 into lp:gcc-linaro/4.6

Proposed by Andrew Stubbs
Status: Work in progress
Proposed branch: lp:~ams-codesourcery/gcc-linaro/lp641397-4.6
Merge into: lp:gcc-linaro/4.6
Diff against target: 80 lines (+30/-6)
3 files modified
ChangeLog.linaro (+8/-0)
gcc/cse.c (+21/-5)
gcc/passes.c (+1/-1)
To merge this branch: bzr merge lp:~ams-codesourcery/gcc-linaro/lp641397-4.6
Reviewer Review Type Date Requested Status
Linaro Toolchain Developers Pending
Review via email: mp+48007@code.launchpad.net

Description of the change

This patch has been posted for upstream review here:
 http://old.nabble.com/-patch,-CSE--Bit-field-insertion-optimization-to30418376.html

The patch needs follow up. It's not obvious that it will ever be acceptable. I'm posting this merge request so as not to lose it.

To post a comment you must log in.

Unmerged revisions

105757. By Andrew Stubbs

Fix a missed optimization in bitfield initialization.

LP:641397

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'ChangeLog.linaro'
2--- ChangeLog.linaro 1970-01-01 00:00:00 +0000
3+++ ChangeLog.linaro 2011-01-31 15:39:37 +0000
4@@ -0,0 +1,8 @@
5+2010-12-09 Andrew Stubbs <ams@codesourcery.com>
6+
7+ gcc/
8+ * cse.c (cse_insn): Add support for ZERO_EXTRACT with a register
9+ source operand.
10+ * passes.c (init_optimization_passes): Move initialize_regs
11+ before cse2.
12+
13
14=== modified file 'gcc/cse.c'
15--- gcc/cse.c 2010-10-14 07:17:54 +0000
16+++ gcc/cse.c 2011-01-31 15:39:37 +0000
17@@ -5036,7 +5036,6 @@
18 (set (zero_extract:M2 (reg:M N) (const_int C) (const_int D))
19 (reg:M2 O)). */
20 if (GET_CODE (SET_DEST (sets[i].rtl)) == ZERO_EXTRACT
21- && CONST_INT_P (trial)
22 && CONST_INT_P (XEXP (SET_DEST (sets[i].rtl), 1))
23 && CONST_INT_P (XEXP (SET_DEST (sets[i].rtl), 2))
24 && REG_P (XEXP (SET_DEST (sets[i].rtl), 0))
25@@ -5052,9 +5051,26 @@
26 unsigned int dest_hash = HASH (dest_reg, GET_MODE (dest_reg));
27 struct table_elt *dest_elt
28 = lookup (dest_reg, dest_hash, GET_MODE (dest_reg));
29- rtx dest_cst = NULL;
30-
31- if (dest_elt)
32+ rtx dest_cst = NULL, src_cst = NULL;
33+
34+ if (CONST_INT_P (trial))
35+ src_cst = trial;
36+ else if (REG_P (trial))
37+ {
38+ unsigned int src_hash = HASH (trial, GET_MODE (trial));
39+ struct table_elt *src_elt
40+ = lookup (trial, src_hash, GET_MODE (trial));
41+
42+ if (src_elt)
43+ for (p = src_elt->first_same_value; p; p = p->next_same_value)
44+ if (p->is_const && CONST_INT_P (p->exp))
45+ {
46+ src_cst = p->exp;
47+ break;
48+ }
49+ }
50+
51+ if (src_cst && dest_elt)
52 for (p = dest_elt->first_same_value; p; p = p->next_same_value)
53 if (p->is_const && CONST_INT_P (p->exp))
54 {
55@@ -5076,7 +5092,7 @@
56 else
57 mask = ((HOST_WIDE_INT) 1 << INTVAL (width)) - 1;
58 val &= ~(mask << shift);
59- val |= (INTVAL (trial) & mask) << shift;
60+ val |= (INTVAL (src_cst) & mask) << shift;
61 val = trunc_int_for_mode (val, GET_MODE (dest_reg));
62 validate_unshare_change (insn, &SET_DEST (sets[i].rtl),
63 dest_reg, 1);
64
65=== modified file 'gcc/passes.c'
66--- gcc/passes.c 2010-11-29 14:09:41 +0000
67+++ gcc/passes.c 2011-01-31 15:39:37 +0000
68@@ -990,11 +990,11 @@
69 }
70 NEXT_PASS (pass_web);
71 NEXT_PASS (pass_rtl_cprop);
72+ NEXT_PASS (pass_initialize_regs);
73 NEXT_PASS (pass_cse2);
74 NEXT_PASS (pass_rtl_dse1);
75 NEXT_PASS (pass_rtl_fwprop_addr);
76 NEXT_PASS (pass_inc_dec);
77- NEXT_PASS (pass_initialize_regs);
78 NEXT_PASS (pass_ud_rtl_dce);
79 NEXT_PASS (pass_combine);
80 NEXT_PASS (pass_if_after_combine);

Subscribers

People subscribed via source and target branches