This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/27971] eliminate shift in array[(x>>2)&3]
- From: "raksit at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2007 19:27:59 -0000
- Subject: [Bug target/27971] eliminate shift in array[(x>>2)&3]
- References: <bug-27971-5748@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from raksit at google dot com 2007-12-05 19:27 -------
For the rtl emitted on x86 processors, the combiner is almost able to optimize
the shift away. It combines and simplifies the 3 instructions down to:
Failed to match this instruction:
(set (reg:SI 64)
(mem/s:SI (plus:SI (and:SI (reg/v:SI 59 [ x ])
(const_int 12 [0xc]))
(symbol_ref:SI ("array") <var_decl 0xf7ef20b0 array>)) [3
array S4 A32]))
It gives up at this point. The solution is to introduce a split to do the AND,
followed by the load. This can be done in machine-independent way by modifying
find_split_point in combine.c. Patch coming up shortly.
-raksit
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27971