This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/19721] [meta-bug] optimizations that CSE still catches
- From: "stevenb at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Mar 2005 10:39:53 -0000
- Subject: [Bug middle-end/19721] [meta-bug] optimizations that CSE still catches
- References: <20050131123257.19721.steven@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From stevenb at suse dot de 2005-03-05 10:39 -------
Subject: Re: [meta-bug] optimizations that CSE still catches
> Am I missing something here? I guess I'm not sure what point you're
> trying to make.
It just seems that we could do better on initial RTL generation, e.g.
;; j = k * -1
(insn 23 21 0 (parallel [
(set (reg/v:DI 64 [ j ])
(mult:DI (reg/v:DI 67 [ k ])
(const_int -1 [0xffffffffffffffff])))
(clobber (reg:CC 17 flags))
]) -1 (nil)
(nil))
which we later simplify in CSE:
Working on insn:
(insn 23 21 24 0 (parallel [
(set (reg/v:DI 64 [ j ])
(mult:DI (reg/v:DI 67 [ k ])
(const_int -1 [0xffffffffffffffff])))
(clobber (reg:CC 17 flags))
]) 243 {*muldi3_1_rex64} (nil)
(nil))
Trying to fold rtx:
(mult:DI (reg/v:DI 67 [ k ])
(const_int -1 [0xffffffffffffffff]))
Returning new rtx:
(neg:DI (reg/v:DI 67 [ k ]))
Similarly, on a 64-bits host:
;; j = k * 4294967295
(insn 15 13 16 (set (reg:DI 63)
(reg/v:DI 62 [ k ])) -1 (nil)
(nil))
(insn 16 15 17 (parallel [
(set (reg:DI 64)
(ashift:DI (reg:DI 63)
(const_int 32 [0x20])))
(clobber (reg:CC 17 flags))
]) -1 (nil)
(expr_list:REG_EQUAL (mult:DI (reg/v:DI 62 [ k ])
(const_int 4294967296 [0x100000000]))
(nil)))
(insn 17 16 18 (parallel [
(set (reg:DI 65)
(minus:DI (reg:DI 64)
(reg/v:DI 62 [ k ])))
(clobber (reg:CC 17 flags))
]) -1 (nil)
(expr_list:REG_EQUAL (mult:DI (reg/v:DI 62 [ k ])
(const_int 4294967295 [0xffffffff]))
(nil)))
(insn 18 17 0 (set (reg/v:DI 59 [ j ])
(reg:DI 65)) -1 (nil)
(nil))
which CSE turns into:
Working on insn:
(insn 15 13 16 0 (set (reg:DI 63 [ k ])
(reg/v:DI 62 [ k ])) 81 {*movdi_1_rex64} (nil)
(nil))
Trying to fold rtx:
(reg/v:DI 62 [ k ])
Returning X unchanged.
Working on insn:
(insn 16 15 17 0 (parallel [
(set (reg:DI 64)
(ashift:DI (reg:DI 63 [ k ])
(const_int 32 [0x20])))
(clobber (reg:CC 17 flags))
]) -1 (nil)
(expr_list:REG_EQUAL (mult:DI (reg/v:DI 62 [ k ])
(const_int 4294967296 [0x100000000]))
(nil)))
Trying to fold rtx:
(mult:DI (reg/v:DI 62 [ k ])
(const_int 4294967296 [0x100000000]))
Returning new rtx:
(ashift:DI (reg/v:DI 62 [ k ])
(const_int 32 [0x20]))
Working on insn:
(insn 17 16 18 0 (parallel [
(set (reg:DI 65)
(minus:DI (reg:DI 64)
(reg/v:DI 62 [ k ])))
(clobber (reg:CC 17 flags))
]) 223 {*subdi_1_rex64} (nil)
(expr_list:REG_EQUAL (mult:DI (reg/v:DI 62 [ k ])
(const_int 4294967295 [0xffffffff]))
(nil)))
Trying to fold rtx:
(minus:DI (reg:DI 64)
(reg/v:DI 62 [ k ]))
Returning X unchanged.
Working on insn:
(insn 18 17 19 0 (set (reg/v:DI 59 [ j ])
(reg:DI 65)) 81 {*movdi_1_rex64} (nil)
(nil))
Trying to fold rtx:
(reg:DI 65)
Returning X unchanged.
These are the from the detailed .expand dump
(i.e. "cc1 t.c -O2 --fdump-rtl-expand-details -fdump-rtl-cse")
So it seems to come from the MULT_EXPR expander in this case, but
we'll have to study expand a bit closer to be sure.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19721