* [Bug c/104839] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
@ 2022-03-08 11:34 ` vstinner at redhat dot com
2022-03-08 13:10 ` [Bug target/104839] [12 Regression] " redi at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: vstinner at redhat dot com @ 2022-03-08 11:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #1 from Victor Stinner <vstinner at redhat dot com> ---
Thanks Miro Hrončok who identified the Cython regressiond and wrote a Cython
reproducer. Thanks Serge Guelton who helped me to write a shorter C reproducer.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
2022-03-08 11:34 ` [Bug c/104839] " vstinner at redhat dot com
@ 2022-03-08 13:10 ` redi at gcc dot gnu.org
2022-03-08 13:17 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-08 13:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |12.0
Summary|ppc64 regression of GCC 12: |[12 Regression] ppc64
|conditional long += long |regression of GCC 12:
|becomes unconditional SUBFC |conditional long += long
| |becomes unconditional SUBFC
Status|UNCONFIRMED |NEW
Known to work| |11.2.1
Ever confirmed|0 |1
Target Milestone|--- |12.0
Keywords| |wrong-code
Component|c |target
Last reconfirmed| |2022-03-08
Target|powerpc64le |powerpc64le-unknown-linux-g
| |nu
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
2022-03-08 11:34 ` [Bug c/104839] " vstinner at redhat dot com
2022-03-08 13:10 ` [Bug target/104839] [12 Regression] " redi at gcc dot gnu.org
@ 2022-03-08 13:17 ` redi at gcc dot gnu.org
2022-03-08 13:24 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-08 13:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The test fails with -O1 and passes with -O1 -fno-forward-propagate
Also, the test passes with -Og and fails with -Og -fif-conversion
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (2 preceding siblings ...)
2022-03-08 13:17 ` redi at gcc dot gnu.org
@ 2022-03-08 13:24 ` jakub at gcc dot gnu.org
2022-03-08 14:12 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-08 13:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly adjusted testcase, so that it aborts on miscompilation:
__attribute__((noipa)) short
foo (void)
{
return -1;
}
__attribute__((noipa)) int
bar (void)
{
short i = foo ();
if (i == -2)
return 2;
long k = i;
int j = -1;
volatile long s = 300;
if (k < 0)
{
k += s;
if (k < 0)
j = 0;
}
else if (k >= s)
j = 0;
if (j != -1)
return 1;
return 0;
}
int
main ()
{
if (bar () != 0)
__builtin_abort ();
return 0;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (3 preceding siblings ...)
2022-03-08 13:24 ` jakub at gcc dot gnu.org
@ 2022-03-08 14:12 ` jakub at gcc dot gnu.org
2022-03-08 15:08 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-08 14:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r12-3252-gcad36f38576a6a781e3c62ab061c68f5b8dab13a
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (4 preceding siblings ...)
2022-03-08 14:12 ` jakub at gcc dot gnu.org
@ 2022-03-08 15:08 ` jakub at gcc dot gnu.org
2022-03-08 15:40 ` [Bug rtl-optimization/104839] " jakub at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-08 15:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This goes wrong during fwprop1.
In #c3 testcase at -O2 in bar we have before fwprop1:
(call_insn 6 2 7 2 (parallel [
(set (reg:DI 3 3)
(call (mem:SI (symbol_ref:DI ("foo") [flags 0x3]
<function_decl 0x7fb75851b400 foo>) [0 foo S4 A8])
(const_int 0 [0])))
(use (const_int 0 [0]))
(clobber (reg:DI 96 lr))
]) "pr104839.c":10:13 755 {*call_value_localdi}
(expr_list:REG_CALL_DECL (symbol_ref:DI ("foo") [flags 0x3]
<function_decl 0x7fb75851b400 foo>)
(nil))
(expr_list (use (reg:DI 2 2))
(nil)))
(insn 7 6 8 2 (set (reg:DI 126)
(reg:DI 3 3)) "pr104839.c":10:13 670 {*movdi_internal64}
(nil))
(insn 8 7 9 2 (set (reg/v:HI 119 [ i ])
(subreg/s/u:HI (reg:DI 126) 0)) "pr104839.c":10:13 552
{*movhi_internal}
(nil))
(insn 9 8 10 2 (set (reg:SI 127)
(sign_extend:SI (reg/v:HI 119 [ i ]))) "pr104839.c":11:6 25
{*extendhisi2}
(nil))
(insn 10 9 11 2 (set (reg:SI 128)
(const_int -2 [0xfffffffffffffffe])) "pr104839.c":11:6 546
{*movsi_internal1}
(nil))
(insn 11 10 12 2 (set (reg:CC 129)
(compare:CC (reg:SI 127)
(reg:SI 128))) "pr104839.c":11:6 785 {*cmpsi_signed}
(nil))
which looks good to me, the function returns signed short and ppc64{,le} ABI
says that in that case the value is returned sign-extended into %r3.
subreg/s/u stands for promoted sign-extended.
But fwprop changes insns 8 to 11 into:
(insn 11 7 12 2 (set (reg:CC 129)
(compare:CC (subreg/s/v:SI (reg:DI 126) 0)
(const_int -2 [0xfffffffffffffffe]))) "pr104839.c":11:6 785
{*cmpsi_signed}
(nil))
where subreg/s/v stands for promoted zero-extended. That is wrong.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (5 preceding siblings ...)
2022-03-08 15:08 ` jakub at gcc dot gnu.org
@ 2022-03-08 15:40 ` jakub at gcc dot gnu.org
2022-03-09 8:13 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-08 15:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Component|target |rtl-optimization
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (6 preceding siblings ...)
2022-03-08 15:40 ` [Bug rtl-optimization/104839] " jakub at gcc dot gnu.org
@ 2022-03-09 8:13 ` cvs-commit at gcc dot gnu.org
2022-03-09 8:17 ` jakub at gcc dot gnu.org
2022-03-09 9:04 ` vstinner at redhat dot com
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-09 8:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #6 from CVS 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:7ca24ae5701769fccabf8cca4cad6987cb2187c6
commit r12-7556-g7ca24ae5701769fccabf8cca4cad6987cb2187c6
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Mar 9 09:12:38 2022 +0100
simplify-rtx: Fix up SUBREG_PROMOTED_SET arguments [PR104839]
The following testcase is miscompiled on powerpc64le-linux at -O1 and
higher
(except for -Og). The bug was introduced in r12-3252-gcad36f38576a6a7
which for SIGN_EXTEND from SUBREG_PROMOTED_SIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 1) (but that makes temp
SUBREG_PROMOTED_UNSIGNED_P because SRP_UNSIGNED is 1) and similarly the
ZERO_EXTEND from SUBREG_PROMOTED_UNSIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 0) (but that makes temp
SUBREG_PROMOTED_SIGNED_P because SRP_SIGNED is 0).
The following patch fixes that (swaps the 0s and 1s), but for better
readability uses the SRP_* constants.
rtl.h has:
/* Valid for subregs which are SUBREG_PROMOTED_VAR_P(). In that case
this gives the necessary extensions:
0 - signed (SPR_SIGNED)
1 - normal unsigned (SPR_UNSIGNED)
2 - value is both sign and unsign extended for mode
(SPR_SIGNED_AND_UNSIGNED).
-1 - pointer unsigned, which most often can be handled like unsigned
extension, except for generating instructions where we need to
emit special code (ptr_extend insns) on some architectures
(SPR_POINTER). */
The expr.c change in the same commit looks ok to me (passes unsignedp
to SUBREG_PROMOTED_SET, so 0 for signed, 1 for unsigned).
2022-03-09 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/104839
* simplify-rtx.cc (simplify_unary_operation_1) <case SIGN_EXTEND>:
Use SRP_SIGNED instead of incorrect 1 in SUBREG_PROMOTED_SET.
(simplify_unary_operation_1) <case ZERO_EXTEND>: Use SRP_UNSIGNED
instead of incorrect 0 in SUBREG_PROMOTED_SET.
* gcc.c-torture/execute/pr104839.c: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (7 preceding siblings ...)
2022-03-09 8:13 ` cvs-commit at gcc dot gnu.org
@ 2022-03-09 8:17 ` jakub at gcc dot gnu.org
2022-03-09 9:04 ` vstinner at redhat dot com
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-09 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/104839] [12 Regression] ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
` (8 preceding siblings ...)
2022-03-09 8:17 ` jakub at gcc dot gnu.org
@ 2022-03-09 9:04 ` vstinner at redhat dot com
9 siblings, 0 replies; 11+ messages in thread
From: vstinner at redhat dot com @ 2022-03-09 9:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839
--- Comment #8 from Victor Stinner <vstinner at redhat dot com> ---
> Fixed.
Thank you! That was quick!
^ permalink raw reply [flat|nested] 11+ messages in thread