public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/101205] New: csinv does not have an zero_extend version
@ 2021-06-25  7:56 pinskia at gcc dot gnu.org
  2021-07-16 23:08 ` [Bug target/101205] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-25  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101205
           Summary: csinv does not have an zero_extend version
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

While improving phi-opt I ran into this issue.
gcc.target/aarch64/csinv-neg.c started to fail because we move the cast out of
the conditional and such.
Here is a testcase which shows the problem even without improvment of phiopt:
unsigned long long
inv1(unsigned a, unsigned b, unsigned c)
{
  unsigned t = a ? b : ~c;
  return t;
}

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
@ 2021-07-16 23:08 ` pinskia at gcc dot gnu.org
  2021-07-17  7:54 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-16 23:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-16
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
  2021-07-16 23:08 ` [Bug target/101205] " pinskia at gcc dot gnu.org
@ 2021-07-17  7:54 ` pinskia at gcc dot gnu.org
  2021-07-17  8:01 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-17  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem is csinv3si_insn, csinv3_uxtw_insn2, nor csinv3_uxtw_insn3 would
match as those have the zero_extend inside the if/then/else rather on the
outside which is being matched here:
Trying 36 -> 19:
   36: r94:SI={(cc:CC==0)?~r100:SI:r101:SI}
      REG_DEAD r100:SI
      REG_DEAD cc:CC
      REG_DEAD r101:SI
   19: x0:DI=zero_extend(r94:SI)
      REG_DEAD r94:SI
Failed to match this instruction:
(set (reg/i:DI 0 x0)
    (zero_extend:DI (if_then_else:SI (eq (reg:CC 66 cc)
                (const_int 0 [0]))
            (not:SI (reg:SI 100))
            (reg:SI 101))))

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
  2021-07-16 23:08 ` [Bug target/101205] " pinskia at gcc dot gnu.org
  2021-07-17  7:54 ` pinskia at gcc dot gnu.org
@ 2021-07-17  8:01 ` pinskia at gcc dot gnu.org
  2021-07-17  8:15 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-17  8:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The fix actually might be simplier than I had expected because csneg is already
implement, just need to extend it to csinv also like so:
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index f12a0bebd3d..8cd259fca9c 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -4203,15 +4203,15 @@ (define_insn "*csinv3<mode>_insn"
   [(set_attr "type" "csel")]
 )

-(define_insn "csneg3_uxtw_insn"
+(define_insn "*cs<neg_not_cs>3_uxtw_insn4"
   [(set (match_operand:DI 0 "register_operand" "=r")
        (zero_extend:DI
          (if_then_else:SI
            (match_operand 1 "aarch64_comparison_operation" "")
-           (neg:SI (match_operand:SI 2 "register_operand" "r"))
+           (NEG_NOT:SI (match_operand:SI 2 "register_operand" "r"))
            (match_operand:SI 3 "aarch64_reg_or_zero" "rZ"))))]
   ""
-  "csneg\\t%w0, %w3, %w2, %M1"
+  "cs<neg_not_cs>\\t%w0, %w3, %w2, %M1"
   [(set_attr "type" "csel")]
 )

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-17  8:01 ` pinskia at gcc dot gnu.org
@ 2021-07-17  8:15 ` pinskia at gcc dot gnu.org
  2021-07-17 17:42 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-17  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> The fix actually might be simplier than I had expected because csneg is
> already implement, just need to extend it to csinv also like so:

Yep that works. time to test it.

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-17  8:15 ` pinskia at gcc dot gnu.org
@ 2021-07-17 17:42 ` pinskia at gcc dot gnu.org
  2021-07-17 18:05 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-17 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51169
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51169&action=edit
full patch

Patch which I sent but the company mail relay server looks broken.

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-17 17:42 ` pinskia at gcc dot gnu.org
@ 2021-07-17 18:05 ` pinskia at gcc dot gnu.org
  2021-07-19 15:55 ` cvs-commit at gcc dot gnu.org
  2021-07-19 15:56 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-17 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2021-July/57
                   |                            |5514.html

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Finally went through.

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-17 18:05 ` pinskia at gcc dot gnu.org
@ 2021-07-19 15:55 ` cvs-commit at gcc dot gnu.org
  2021-07-19 15:56 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-19 15:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

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

commit r12-2395-gdb95ac7745b284d1fd667ee6262b4afc778fe074
Author: Andrew Pinski <apinski@marvell.com>
Date:   Sat Jul 17 01:16:28 2021 -0700

    [AARCH64] Fix PR 101205: csinv does not have an zero_extend version

    So the problem is even though there was a csneg with
    a zero_extend in the front, there was not one for csinv.
    This fixes it by extending that pattern.

    OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions.

    gcc/ChangeLog:

            PR target/101205
            * config/aarch64/aarch64.md (csneg3_uxtw_insn): Rename to ...
            (*cs<neg_not_cs>3_uxtw_insn4): and extend to NEG_NOT.

    gcc/testsuite/ChangeLog:

            PR target/101205
            * gcc.target/aarch64/csinv-neg-1.c: New test.

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

* [Bug target/101205] csinv does not have an zero_extend version
  2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-07-19 15:55 ` cvs-commit at gcc dot gnu.org
@ 2021-07-19 15:56 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-19 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-07-19 15:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  7:56 [Bug target/101205] New: csinv does not have an zero_extend version pinskia at gcc dot gnu.org
2021-07-16 23:08 ` [Bug target/101205] " pinskia at gcc dot gnu.org
2021-07-17  7:54 ` pinskia at gcc dot gnu.org
2021-07-17  8:01 ` pinskia at gcc dot gnu.org
2021-07-17  8:15 ` pinskia at gcc dot gnu.org
2021-07-17 17:42 ` pinskia at gcc dot gnu.org
2021-07-17 18:05 ` pinskia at gcc dot gnu.org
2021-07-19 15:55 ` cvs-commit at gcc dot gnu.org
2021-07-19 15:56 ` pinskia at gcc dot gnu.org

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).