public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-03 14:00 ` david.bolvansky at gmail dot com
2020-08-03 14:01 ` david.bolvansky at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: david.bolvansky at gmail dot com @ 2020-08-03 14:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
Dávid Bolvanský <david.bolvansky at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |david.bolvansky at gmail dot com
--- Comment #5 from Dávid Bolvanský <david.bolvansky at gmail dot com> ---
Codegen:
https://godbolt.org/z/7EvYj9
foo:
movabs rdx, -6148914691236517205
mov rax, rdi
mul rdx
mov rax, rdx
and rdx, -2
shr rax
add rdx, rax
xor eax, eax
cmp rdi, rdx
setnb al
ret
N:
.quad 3
Can be optimized to return true
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
2020-08-03 14:00 ` [Bug rtl-optimization/31799] Failed to optimize out test instruction david.bolvansky at gmail dot com
@ 2020-08-03 14:01 ` david.bolvansky at gmail dot com
2020-11-17 10:06 ` gabravier at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: david.bolvansky at gmail dot com @ 2020-08-03 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
--- Comment #6 from Dávid Bolvanský <david.bolvansky at gmail dot com> ---
^ Posted by mistake. Sorry.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
2020-08-03 14:00 ` [Bug rtl-optimization/31799] Failed to optimize out test instruction david.bolvansky at gmail dot com
2020-08-03 14:01 ` david.bolvansky at gmail dot com
@ 2020-11-17 10:06 ` gabravier at gmail dot com
2020-11-17 13:57 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: gabravier at gmail dot com @ 2020-11-17 10:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
Gabriel Ravier <gabravier at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gabravier at gmail dot com
--- Comment #7 from Gabriel Ravier <gabravier at gmail dot com> ---
Seems to now be fixed, I don't see this happening on GCC trunk at the very
least.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2020-11-17 10:06 ` gabravier at gmail dot com
@ 2020-11-17 13:57 ` hjl.tools at gmail dot com
2020-11-17 14:05 ` cvs-commit at gcc dot gnu.org
2020-11-17 14:05 ` hjl.tools at gmail dot com
5 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2020-11-17 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
It is fixed by r8-647.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2020-11-17 13:57 ` hjl.tools at gmail dot com
@ 2020-11-17 14:05 ` cvs-commit at gcc dot gnu.org
2020-11-17 14:05 ` hjl.tools at gmail dot com
5 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-17 14:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:
https://gcc.gnu.org/g:7f87b4ef2323769bd71f7ccea2aa6017a7376f76
commit r11-5090-g7f87b4ef2323769bd71f7ccea2aa6017a7376f76
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Nov 17 06:01:41 2020 -0800
x86: Add a testcase for PR target/31799
Add a testcase for PR target/31799 which was fixed by
commit 4f0473fe89e68bf7c09542ee5c3684da25a5b435
Author: Uros Bizjak <ubizjak@gmail.com>
Date: Fri May 12 21:04:05 2017 +0200
compare-elim.c (try_eliminate_compare): Canonicalize operation with
embedded compare to [(set (reg:CCM) (compare:CCM...
* compare-elim.c (try_eliminate_compare): Canonicalize
operation with embedded compare to
[(set (reg:CCM) (compare:CCM (operation) (immediate)))
(set (reg) (operation)].
* config/i386/i386.c (TARGET_FLAGS_REGNUM): New define.
in GCC 8.
PR target/31799
* gcc.target/i386/pr31799.c: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2020-11-17 14:05 ` cvs-commit at gcc dot gnu.org
@ 2020-11-17 14:05 ` hjl.tools at gmail dot com
5 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2020-11-17 14:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
Target Milestone|--- |8.0
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed in GCC 8.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
2007-05-03 14:21 [Bug rtl-optimization/31799] New: " hjl at lucon dot org
` (2 preceding siblings ...)
2007-05-05 1:31 ` hjl at lucon dot org
@ 2007-05-05 17:49 ` ubizjak at gmail dot com
3 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2007-05-05 17:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ubizjak at gmail dot com 2007-05-05 18:49 -------
(In reply to comment #3)
> The problem may be patterns like
No, the patterns are OK. Combine pass merges these patterns without problems.
But without links, combine doesn't even try to merge them.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
2007-05-03 14:21 [Bug rtl-optimization/31799] New: " hjl at lucon dot org
2007-05-03 16:08 ` [Bug rtl-optimization/31799] " ubizjak at gmail dot com
2007-05-03 16:22 ` ubizjak at gmail dot com
@ 2007-05-05 1:31 ` hjl at lucon dot org
2007-05-05 17:49 ` ubizjak at gmail dot com
3 siblings, 0 replies; 10+ messages in thread
From: hjl at lucon dot org @ 2007-05-05 1:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl at lucon dot org 2007-05-05 02:31 -------
The problem may be patterns like
[(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
(match_operand:SI 2 "general_operand" "rmni,rni,lni")))
(clobber (reg:CC FLAGS_REG))]
What if we replace (clobber (reg:CC FLAGS_REG)) with something more
reasonable like
(set (reg FLAGS_REG)
(compare
(plus:SI (match_dup 1) (match_dup 2))
(const_int 0)))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
2007-05-03 14:21 [Bug rtl-optimization/31799] New: " hjl at lucon dot org
2007-05-03 16:08 ` [Bug rtl-optimization/31799] " ubizjak at gmail dot com
@ 2007-05-03 16:22 ` ubizjak at gmail dot com
2007-05-05 1:31 ` hjl at lucon dot org
2007-05-05 17:49 ` ubizjak at gmail dot com
3 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2007-05-03 16:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ubizjak at gmail dot com 2007-05-03 17:22 -------
Ah, for some reason insn 13 does not have the insn link pointing to insn 10.
Probably dataflow should/could fix this?
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/31799] Failed to optimize out test instruction
2007-05-03 14:21 [Bug rtl-optimization/31799] New: " hjl at lucon dot org
@ 2007-05-03 16:08 ` ubizjak at gmail dot com
2007-05-03 16:22 ` ubizjak at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2007-05-03 16:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ubizjak at gmail dot com 2007-05-03 17:08 -------
(In reply to comment #0)
> foo:
> addl $1, %edi
> testl %edi, %edi
> movl %edi, (%rdx)
> je .L3
> movl $1, (%rsi)
> .L3:
> rep ; ret
This is just an unfortunate corner case. During combine phase we get:
(insn 10 6 11 2 (parallel [
(set (reg/v:SI 58 [ x.27 ])
(plus:SI (reg/v:SI 59 [ x ])
(const_int 1 [0x1])))
(clobber (reg:CC 17 flags))
]) 210 {*addsi_1} (insn_list:REG_DEP_TRUE 3 (nil))
(expr_list:REG_DEAD (reg/v:SI 59 [ x ])
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
(insn 11 10 13 2 (set (mem:SI (reg/v/f:DI 61 [ z ]) [2 S4 A32])
(reg/v:SI 58 [ x.27 ])) 40 {*movsi_1} (insn_list:REG_DEP_TRUE 5
(insn_list:REG_DEP_TRUE 10 (nil)))
(expr_list:REG_DEAD (reg/v/f:DI 61 [ z ])
(nil)))
(insn 13 11 14 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg/v:SI 58 [ x.27 ])
(const_int -1 [0xffffffffffffffff]))) 5 {*cmpsi_1_insn} (nil)
(expr_list:REG_DEAD (reg/v:SI 58 [ x.27 ])
(nil)))
It looks that insn 10 and insn 13 don't combine into flags setting insn due to
insn 11 interfering in some way. If the code is changed to:
void
foo (int x, int *y, int *z)
{
if (++x != 0)
*y = 1;
*z = x;
}
then gcc generates expected asm without test insn.
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-05-03 17:08:39
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31799
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-11-17 14:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-31799-4@http.gcc.gnu.org/bugzilla/>
2020-08-03 14:00 ` [Bug rtl-optimization/31799] Failed to optimize out test instruction david.bolvansky at gmail dot com
2020-08-03 14:01 ` david.bolvansky at gmail dot com
2020-11-17 10:06 ` gabravier at gmail dot com
2020-11-17 13:57 ` hjl.tools at gmail dot com
2020-11-17 14:05 ` cvs-commit at gcc dot gnu.org
2020-11-17 14:05 ` hjl.tools at gmail dot com
2007-05-03 14:21 [Bug rtl-optimization/31799] New: " hjl at lucon dot org
2007-05-03 16:08 ` [Bug rtl-optimization/31799] " ubizjak at gmail dot com
2007-05-03 16:22 ` ubizjak at gmail dot com
2007-05-05 1:31 ` hjl at lucon dot org
2007-05-05 17:49 ` ubizjak at gmail 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).