public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns
       [not found] <bug-91865-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-04 12:31 ` rguenth at gcc dot gnu.org
  2023-10-26  9:11 ` cvs-commit at gcc dot gnu.org
  2023-11-12 15:44 ` roger at nextmovesoftware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 12:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91865

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

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

* [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns
       [not found] <bug-91865-4@http.gcc.gnu.org/bugzilla/>
  2021-05-04 12:31 ` [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns rguenth at gcc dot gnu.org
@ 2023-10-26  9:11 ` cvs-commit at gcc dot gnu.org
  2023-11-12 15:44 ` roger at nextmovesoftware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-26  9:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91865

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:d1bb9569d7030490fe7bb35af432f934560d689d

commit r14-4941-gd1bb9569d7030490fe7bb35af432f934560d689d
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Thu Oct 26 10:06:59 2023 +0100

    PR 91865: Avoid ZERO_EXTEND of ZERO_EXTEND in make_compound_operation.

    This patch is my proposed solution to PR rtl-optimization/91865.
    Normally RTX simplification canonicalizes a ZERO_EXTEND of a ZERO_EXTEND
    to a single ZERO_EXTEND, but as shown in this PR it is possible for
    combine's make_compound_operation to unintentionally generate a
    non-canonical ZERO_EXTEND of a ZERO_EXTEND, which is unlikely to be
    matched by the backend.

    For the new test case:

    const int table[2] = {1, 2};
    int foo (char i) { return table[i]; }

    compiling with -O2 -mlarge on msp430 we currently see:

    Trying 2 -> 7:
        2: r25:HI=zero_extend(R12:QI)
          REG_DEAD R12:QI
        7: r28:PSI=sign_extend(r25:HI)#0
          REG_DEAD r25:HI
    Failed to match this instruction:
    (set (reg:PSI 28 [ iD.1772 ])
        (zero_extend:PSI (zero_extend:HI (reg:QI 12 R12 [ iD.1772 ]))))

    which results in the following code:

    foo:    AND     #0xff, R12
            RLAM.A #4, R12 { RRAM.A #4, R12
            RLAM.A  #1, R12
            MOVX.W  table(R12), R12
            RETA

    With this patch, we now see:

    Trying 2 -> 7:
        2: r25:HI=zero_extend(R12:QI)
          REG_DEAD R12:QI
        7: r28:PSI=sign_extend(r25:HI)#0
          REG_DEAD r25:HI
    Successfully matched this instruction:
    (set (reg:PSI 28 [ iD.1772 ])
        (zero_extend:PSI (reg:QI 12 R12 [ iD.1772 ])))
    allowing combination of insns 2 and 7
    original costs 4 + 8 = 12
    replacement cost 8

    foo:    MOV.B   R12, R12
            RLAM.A  #1, R12
            MOVX.W  table(R12), R12
            RETA

    2023-10-26  Roger Sayle  <roger@nextmovesoftware.com>
                Richard Biener  <rguenther@suse.de>

    gcc/ChangeLog
            PR rtl-optimization/91865
            * combine.cc (make_compound_operation): Avoid creating a
            ZERO_EXTEND of a ZERO_EXTEND.

    gcc/testsuite/ChangeLog
            PR rtl-optimization/91865
            * gcc.target/msp430/pr91865.c: New test case.

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

* [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns
       [not found] <bug-91865-4@http.gcc.gnu.org/bugzilla/>
  2021-05-04 12:31 ` [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns rguenth at gcc dot gnu.org
  2023-10-26  9:11 ` cvs-commit at gcc dot gnu.org
@ 2023-11-12 15:44 ` roger at nextmovesoftware dot com
  2 siblings, 0 replies; 3+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-11-12 15:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91865

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roger at nextmovesoftware dot com
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Roger Sayle <roger at nextmovesoftware dot com> ---
This should now be fixed on mainline.

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

end of thread, other threads:[~2023-11-12 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91865-4@http.gcc.gnu.org/bugzilla/>
2021-05-04 12:31 ` [Bug rtl-optimization/91865] Combine misses opportunity to remove (sign_extend (zero_extend)) before searching for insn patterns rguenth at gcc dot gnu.org
2023-10-26  9:11 ` cvs-commit at gcc dot gnu.org
2023-11-12 15:44 ` roger at nextmovesoftware dot 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).