public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs
@ 2012-02-13 16:55 Paulo.Matos at csr dot com
  2012-02-13 16:58 ` [Bug rtl-optimization/52235] " Paulo.Matos at csr dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Paulo.Matos at csr dot com @ 2012-02-13 16:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

             Bug #: 52235
           Summary: rtlanal: commutative_operand_precedence should
                    prioritize regs
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Paulo.Matos@csr.com


I noticed the combine receives insns of the form:
(set (reg ...) (ior (mem (reg ...)) (reg ...)))

(in my specific case the reg inside mem was an argument pointer that later
would be eliminated in terms of a function pointer.

After an initial discussion in the mailing list:
http://www.mail-archive.com/gcc@gcc.gnu.org/msg62132.html
Richard pointed me to commutative_operand_precedence. Both him and I expected
to see the register come first.

Having the register come first is more intuitive and under my backend it
performs much better. The whole reason to look into this stemmed from the fact
that commutative operations like ior were not being correctly combined since
the backend rule looked like:
(define_insn "iorqi3"
  [(set (match_operand:QI 0 "register_operand" "=c")
        (ior:QI (match_operand:QI 1 "register_operand" "%0")
                (match_operand:QI 2 "general_operand" "cwmi")))
   (clobber (reg:CC RCC))]
  ""
  "or\\t%0,%f2")

Makes sense for operand1 to be a register_operand because it will be forced to
be the same as operand0. However, if we can't assume registers come first a lot
of rule duplication has to occur in order to achieve the same effect. I would
guess in this case I would need to have instead of the above:
(define_insn "iorqi3"
  [(set (match_operand:QI 0 "register_operand" "=c")
        (ior:QI (match_operand:QI 1 "register_operand" "0")
                (match_operand:QI 2 "general_operand" "cwmi")))
   (clobber (reg:CC RCC))]
  ""
  "or\\t%0,%f2")

(define_insn "iorqi3"
  [(set (match_operand:QI 0 "register_operand" "=c")
        (ior:QI (match_operand:QI 1 "general_operand" "cwmi")
                (match_operand:QI 2 "register_operand" "0")))
   (clobber (reg:CC RCC))]
  ""
  "or\\t%0,%f1")

The simple fix of making registers have priority over everything else works
like a charm. Patch follows.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/52235] rtlanal: commutative_operand_precedence should prioritize regs
  2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
@ 2012-02-13 16:58 ` Paulo.Matos at csr dot com
  2012-02-13 21:10 ` steven at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paulo.Matos at csr dot com @ 2012-02-13 16:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

--- Comment #1 from Paulo J. Matos <Paulo.Matos at csr dot com> 2012-02-13 16:58:17 UTC ---
Created attachment 26651
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26651
Patch to increase regs priority in commutative_operand_precedence


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/52235] rtlanal: commutative_operand_precedence should prioritize regs
  2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
  2012-02-13 16:58 ` [Bug rtl-optimization/52235] " Paulo.Matos at csr dot com
@ 2012-02-13 21:10 ` steven at gcc dot gnu.org
  2012-02-14  7:28 ` Paulo.Matos at csr dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu.org @ 2012-02-13 21:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-13
                 CC|                            |steven at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> 2012-02-13 21:10:08 UTC ---
Can you please post the patch to gcc-patches@gcc.gnu.org?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/52235] rtlanal: commutative_operand_precedence should prioritize regs
  2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
  2012-02-13 16:58 ` [Bug rtl-optimization/52235] " Paulo.Matos at csr dot com
  2012-02-13 21:10 ` steven at gcc dot gnu.org
@ 2012-02-14  7:28 ` Paulo.Matos at csr dot com
  2013-05-08 18:56 ` steven at gcc dot gnu.org
  2013-05-08 20:20 ` paulo@matos-sorge.com
  4 siblings, 0 replies; 6+ messages in thread
From: Paulo.Matos at csr dot com @ 2012-02-14  7:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

--- Comment #3 from Paulo J. Matos <Paulo.Matos at csr dot com> 2012-02-14 07:27:50 UTC ---
Thanks for the reminder Steven. Now submitted.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/52235] rtlanal: commutative_operand_precedence should prioritize regs
  2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
                   ` (2 preceding siblings ...)
  2012-02-14  7:28 ` Paulo.Matos at csr dot com
@ 2013-05-08 18:56 ` steven at gcc dot gnu.org
  2013-05-08 20:20 ` paulo@matos-sorge.com
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu.org @ 2013-05-08 18:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

--- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> 2013-05-08 18:56:35 UTC ---
(In reply to comment #4)
> This issue persists in HEAD, the submitted patch seems to have been forgotten.
> Ping, ping.

Ping it on gcc-patches, BZ is *not* the place for that!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/52235] rtlanal: commutative_operand_precedence should prioritize regs
  2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
                   ` (3 preceding siblings ...)
  2013-05-08 18:56 ` steven at gcc dot gnu.org
@ 2013-05-08 20:20 ` paulo@matos-sorge.com
  4 siblings, 0 replies; 6+ messages in thread
From: paulo@matos-sorge.com @ 2013-05-08 20:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52235

--- Comment #6 from Paulo J. Matos <paulo@matos-sorge.com> 2013-05-08 20:20:00 UTC ---
(In reply to comment #5)
> (In reply to comment #4)
> > This issue persists in HEAD, the submitted patch seems to have been forgotten.
> > Ping, ping.
> 
> Ping it on gcc-patches, BZ is *not* the place for that!

Sorry, ping redirected to gcc-patches.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-08 20:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-13 16:55 [Bug rtl-optimization/52235] New: rtlanal: commutative_operand_precedence should prioritize regs Paulo.Matos at csr dot com
2012-02-13 16:58 ` [Bug rtl-optimization/52235] " Paulo.Matos at csr dot com
2012-02-13 21:10 ` steven at gcc dot gnu.org
2012-02-14  7:28 ` Paulo.Matos at csr dot com
2013-05-08 18:56 ` steven at gcc dot gnu.org
2013-05-08 20:20 ` paulo@matos-sorge.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).