public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
@ 2023-11-18 13:32 tschwinge at gcc dot gnu.org
  2023-11-18 14:05 ` [Bug rtl-optimization/112606] " tnfchris at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2023-11-18 13:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112606
           Summary: [14 Regression] powerpc64le-linux-gnu: 'FAIL:
                    gcc.target/powerpc/p8vector-fp.c scan-assembler
                    xsnabsdp'
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: testsuite-fail
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: pinskia at gcc dot gnu.org, xry111 at gcc dot gnu.org
  Target Milestone: ---
            Target: powerpc64le-linux-gnu

If my tracking is to be believed, the recent commit
r14-5542-g9e9279fadbd1c673c875b9d20261d2de0473f63f "Only allow (copysign x,
NEG_CONST) -> (fneg (fabs x)) simplification for constant folding [PR112483]"
causes a regression for powerpc64le-linux-gnu:

    @@ -169558,7 +169764,7 @@ PASS: gcc.target/powerpc/p8vector-fp.c
scan-assembler xsdivdp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xsdivsp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xsmuldp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xsmulsp
    [-PASS:-]{+FAIL:+} gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnegdp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xssqrtdp
    PASS: gcc.target/powerpc/p8vector-fp.c scan-assembler xssqrtsp

With that commit reverted (PASS) vs. non-reverted (FAIL):

    --- p8vector-fp.s   2023-11-18 14:22:23.862421425 +0100
    +++ p8vector-fp.s   2023-11-18 14:11:49.554421425 +0100
    @@ -33,13 +33,15 @@
     0: addis 2,12,.TOC.-.LCF1@ha
        addi 2,2,.TOC.-.LCF1@l
        .localentry     nabs_sf,.-nabs_sf
    +   addis 9,2,.LC0@toc@ha
        lxsspx 32,0,3
     #APP
      # 16 "[...]/source-gcc/gcc/testsuite/gcc.target/powerpc/p8vector-fp.c" 1
        # reg 32
      # 0 "" 2
     #NO_APP
    -   xsnabsdp 1,32
    +   lfs 1,.LC0@toc@l(9)
    +   xscpsgndp 1,1,32
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0
    @@ -201,13 +203,15 @@
     0: addis 2,12,.TOC.-.LCF9@ha
        addi 2,2,.TOC.-.LCF9@l
        .localentry     nabs_df,.-nabs_df
    +   addis 9,2,.LC2@toc@ha
        lxsdx 32,0,3
     #APP
      # 77 "[...]/source-gcc/gcc/testsuite/gcc.target/powerpc/p8vector-fp.c" 1
        # reg 32
      # 0 "" 2
     #NO_APP
    -   xsnabsdp 1,32
    +   lfd 1,.LC2@toc@l(9)
    +   xscpsgndp 1,1,32
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0
    @@ -338,5 +342,14 @@
        .cfi_endproc
     .LFE15:
        .size   sqrt_df,.-sqrt_df
    +   .section        .rodata.cst4,"aM",@progbits,4
    +   .align 2
    +.LC0:
    +   .long   -1082130432
    +   .section        .rodata.cst8,"aM",@progbits,8
    +   .align 3
    +.LC2:
    +   .long   0
    +   .long   -1074790400
        .gnu_attribute 4, 1
        .section        .note.GNU-stack,"",@progbits

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

* [Bug rtl-optimization/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
@ 2023-11-18 14:05 ` tnfchris at gcc dot gnu.org
  2023-11-18 19:45 ` [Bug target/112606] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2023-11-18 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tnfchris at gcc dot gnu.org

--- Comment #1 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
This looks like a target bug. You seem to have an fneg (fabs (..)) instruction
on powerpc.  This means your copysign pattern needs to either reject the
copysign expansion when the second operand is negative, or it needs to emit
xsnabsdp in this case rather than copysign.

The generic optimization is correct and is doing what the target has requested,
your copysign optab implementation says you prefer it over for any operand.

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
  2023-11-18 14:05 ` [Bug rtl-optimization/112606] " tnfchris at gcc dot gnu.org
@ 2023-11-18 19:45 ` pinskia at gcc dot gnu.org
  2023-11-24 17:59 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-18 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
          Component|rtl-optimization            |target
           Keywords|                            |missed-optimization

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
  2023-11-18 14:05 ` [Bug rtl-optimization/112606] " tnfchris at gcc dot gnu.org
  2023-11-18 19:45 ` [Bug target/112606] " pinskia at gcc dot gnu.org
@ 2023-11-24 17:59 ` jakub at gcc dot gnu.org
  2023-11-28 19:43 ` seurer at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-24 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So
2023-11-24  Jakub Jelinek  <jakub@redhat.com>

        PR target/112606
        * config/rs6000/rs6000.md (copysign<mode>3): Change predicate
        of the last argument from gpc_reg_operand to any_operand.  If
        operands[2] is CONST_DOUBLE, emit abs or neg abs depending on
        its sign, otherwise if it doesn't satisfy gpc_reg_operand,
        force it to REG using copy_to_mode_reg.

--- gcc/config/rs6000/rs6000.md.jj      2023-10-13 19:34:43.927834877 +0200
+++ gcc/config/rs6000/rs6000.md 2023-11-24 18:54:13.587876170 +0100
@@ -5358,7 +5358,7 @@ (define_expand "copysign<mode>3"
    (set (match_dup 4)
        (neg:SFDF (abs:SFDF (match_dup 1))))
    (set (match_operand:SFDF 0 "gpc_reg_operand")
-        (if_then_else:SFDF (ge (match_operand:SFDF 2 "gpc_reg_operand")
+       (if_then_else:SFDF (ge (match_operand:SFDF 2 "any_operand")
                               (match_dup 5))
                         (match_dup 3)
                         (match_dup 4)))]
@@ -5369,6 +5369,24 @@ (define_expand "copysign<mode>3"
        || TARGET_CMPB
        || VECTOR_UNIT_VSX_P (<MODE>mode))"
 {
+  /* Middle-end canonicalizes -fabs (x) to copysign (x, -1),
+     but PowerPC prefers -fabs (x).  */
+  if (CONST_DOUBLE_AS_FLOAT_P (operands[2]))
+    {
+      if (real_isneg (CONST_DOUBLE_REAL_VALUE (operands[2])))
+       {
+         operands[3] = gen_reg_rtx (<MODE>mode);
+         emit_insn (gen_abs<mode>2 (operands[3], operands[1]));
+         emit_insn (gen_neg<mode>2 (operands[0], operands[3]));
+       }
+      else
+       emit_insn (gen_abs<mode>2 (operands[0], operands[1]));
+      DONE;
+    }
+
+  if (!gpc_reg_operand (operands[2], <MODE>mode))
+    operands[2] = copy_to_mode_reg (<MODE>mode, operands[2]);
+
   if (TARGET_CMPB || VECTOR_UNIT_VSX_P (<MODE>mode))
     {
       emit_insn (gen_copysign<mode>3_fcpsgn (operands[0], operands[1],

then?

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-11-24 17:59 ` jakub at gcc dot gnu.org
@ 2023-11-28 19:43 ` seurer at gcc dot gnu.org
  2023-12-05 20:40 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: seurer at gcc dot gnu.org @ 2023-11-28 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

seurer at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |seurer at gcc dot gnu.org

--- Comment #3 from seurer at gcc dot gnu.org ---
These tests also fail starting with g:9e9279fadbd1c673c875b9d20261d2de0473f63f,
r14-5542-g9e9279fadbd1c6

FAIL: gcc.target/powerpc/float128-hw5.c scan-assembler-not \\mxscpsgnqp\\M
FAIL: gcc.target/powerpc/float128-hw5.c scan-assembler-times \\mxsnabsqp\\M 1
FAIL: gcc.target/powerpc/float128-hw7.c scan-assembler-not \\mxscpsgnqp\\M
FAIL: gcc.target/powerpc/float128-hw7.c scan-assembler-times \\mxsnabsqp\\M 1

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-11-28 19:43 ` seurer at gcc dot gnu.org
@ 2023-12-05 20:40 ` cvs-commit at gcc dot gnu.org
  2024-01-08  3:34 ` linkw at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-05 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:58d5546af901364f85588fe668559d76f09e6df9

commit r14-6192-g58d5546af901364f85588fe668559d76f09e6df9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Dec 5 21:39:31 2023 +0100

    rs6000: Canonicalize copysign (x, -1) back to -abs (x) in the backend
[PR112606]

    The middle-end has been changed quite recently to canonicalize
    -abs (x) to copysign (x, -1) rather than the other way around.
    While I agree with that at GIMPLE level, since it matches the GIMPLE
    goal of as few operations as possible for a canonical form (-abs (x)
    is 2 GIMPLE statements, copysign (x, -1) is just one), I must say
    I don't really like that being done on RTL as well (or at least
    not canonicalizing (COPYSIGN x, negative) back to (NEG (ABS x))),
    because on most targets most of floating point constants need to be loaded
    from memory, there are a few exceptions but -1 is often not one of them.

    Anyway, the following patch fixes the rs6000 regression caused by the
    change in GIMPLE canonicalization (i.e. the desirable one).  As rs6000
    clearly prefers -abs (x) form because it has a single instruction to do
    that while it also has copysign instruction, but that requires loading the
    -1 from memory, the following patch just ensures the copysign expander
    can actually see the floating point constant and in that case emits the
    -abs (x) code (or in the hypothetical case of copysign with non-negative
    constant abs (x) - but there copysign (x, 1) in GIMPLE is canonicalized
    to abs (x)), otherwise forces the operand to be the expected
gpc_reg_operand
    and does what it did before.

    2023-12-05  Jakub Jelinek  <jakub@redhat.com>

            PR target/112606
            * config/rs6000/rs6000.md (copysign<mode>3): Change predicate
            of the last argument from gpc_reg_operand to any_operand.  If
            operands[2] is CONST_DOUBLE, emit abs or neg abs depending on
            its sign, otherwise if it doesn't satisfy gpc_reg_operand,
            force it to REG using copy_to_mode_reg.

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-12-05 20:40 ` cvs-commit at gcc dot gnu.org
@ 2024-01-08  3:34 ` linkw at gcc dot gnu.org
  2024-01-10  5:09 ` cvs-commit at gcc dot gnu.org
  2024-01-10  5:20 ` linkw at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-01-08  3:34 UTC (permalink / raw)
  To: gcc-bugs

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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |linkw at gcc dot gnu.org
   Last reconfirmed|                            |2024-01-08
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #5 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to seurer from comment #3)
> These tests also fail starting with
> g:9e9279fadbd1c673c875b9d20261d2de0473f63f, r14-5542-g9e9279fadbd1c6
> 
> FAIL: gcc.target/powerpc/float128-hw5.c scan-assembler-not \\mxscpsgnqp\\M
> FAIL: gcc.target/powerpc/float128-hw5.c scan-assembler-times \\mxsnabsqp\\M 1
> FAIL: gcc.target/powerpc/float128-hw7.c scan-assembler-not \\mxscpsgnqp\\M
> FAIL: gcc.target/powerpc/float128-hw7.c scan-assembler-times \\mxsnabsqp\\M 1

These failures are related to ieee128, the #c4 only handles float/double, a
similar patch was posted for ieee128:
https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642092.html

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-01-08  3:34 ` linkw at gcc dot gnu.org
@ 2024-01-10  5:09 ` cvs-commit at gcc dot gnu.org
  2024-01-10  5:20 ` linkw at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-10  5:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kewen Lin <linkw@gcc.gnu.org>:

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

commit r14-7090-gcf5f6a048e376ab0d2f7bc283c158605e1166061
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Tue Jan 9 23:06:12 2024 -0600

    rs6000: Make copysign (x, -1) back to -abs (x) for IEEE128 float [PR112606]

    I noticed that commit r14-6192 can't help PR112606 #c3 as
    it only takes care of SF/DF but TF/KF can still suffer the
    issue.  Similar to commit r14-6192, this patch is to take
    care of copysign<mode>3 with IEEE128 as well.

            PR target/112606

    gcc/ChangeLog:

            * config/rs6000/rs6000.md (copysign<mode>3 IEEE128): Change
predicate
            of the last argument from altivec_register_operand to any_operand. 
If
            operands[2] is CONST_DOUBLE, emit abs or neg abs depending on its
sign
            otherwise if it doesn't satisfy altivec_register_operand, force it
to
            REG using copy_to_mode_reg.

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

* [Bug target/112606] [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp'
  2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-01-10  5:09 ` cvs-commit at gcc dot gnu.org
@ 2024-01-10  5:20 ` linkw at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-01-10  5:20 UTC (permalink / raw)
  To: gcc-bugs

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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Kewen Lin <linkw at gcc dot gnu.org> ---
Should be fixed on trunk now.

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

end of thread, other threads:[~2024-01-10  5:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-18 13:32 [Bug rtl-optimization/112606] New: [14 Regression] powerpc64le-linux-gnu: 'FAIL: gcc.target/powerpc/p8vector-fp.c scan-assembler xsnabsdp' tschwinge at gcc dot gnu.org
2023-11-18 14:05 ` [Bug rtl-optimization/112606] " tnfchris at gcc dot gnu.org
2023-11-18 19:45 ` [Bug target/112606] " pinskia at gcc dot gnu.org
2023-11-24 17:59 ` jakub at gcc dot gnu.org
2023-11-28 19:43 ` seurer at gcc dot gnu.org
2023-12-05 20:40 ` cvs-commit at gcc dot gnu.org
2024-01-08  3:34 ` linkw at gcc dot gnu.org
2024-01-10  5:09 ` cvs-commit at gcc dot gnu.org
2024-01-10  5:20 ` linkw 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).