public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)"
@ 2003-05-26 13:58 pb@gcc.gnu.org
2003-06-22 3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pb@gcc.gnu.org @ 2003-05-26 13:58 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
Summary: [arm] poor optimisation of "if (var & const)"
Product: gcc
Version: unknown
Status: NEW
Severity: enhancement
Priority: P2
Component: optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pb@gcc.gnu.org
CC: gcc-bugs@gcc.gnu.org
GCC target triplet: arm-linux
Compiling this code:
f(int a)
{
if (a & 0xfff)
return 1;
return 0;
}
with -O2 yields:
mov r0, r0, asl #20
mov r0, r0, lsr #20
cmp r0, #0
movne r0, #1
moveq r0, #0
There's no need to fully calculate the value of the AND, since all that we care
about is whether it's zero or not. So, I think the first three instructions
could be replaced by a single one:
movs r0, r0, asl #20
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug optimization/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
@ 2003-06-22 3:29 ` pinskia at physics dot uc dot edu
2004-05-09 17:11 ` pb at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-06-22 3:29 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4 |---
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug optimization/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
2003-06-22 3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
@ 2004-05-09 17:11 ` pb at gcc dot gnu dot org
2004-05-17 11:27 ` [Bug target/10982] " rearnsha at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pb at gcc dot gnu dot org @ 2004-05-09 17:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pb at gcc dot gnu dot org 2004-05-09 17:11 -------
For that particular testcase, adding a pattern like the one below seems to allow
combine to do the right thing. However, changing the "return 1" to "return 2"
prevents this from matching. Something a bit more sophisticated might be needed.
--
(define_insn_and_split "*zero_extract_compare0_shifted"
[(set (match_operand:SI 0 "s_register_operand" "=r")
(ne:SI (zero_extract:SI (match_operand:SI 1 "s_register_operand" "r")
(match_operand:SI 2 "const_int_operand" "n")
(const_int 0))
(const_int 0)))
(clobber (reg:CC CC_REGNUM))]
"TARGET_ARM"
"#"
""
[(parallel [(set (reg:CC_NOOV CC_REGNUM)
(compare:CC_NOOV (ashift:SI (match_dup 1)
(match_dup 2))
(const_int 0)))
(set (match_dup 0)
(ashift:SI (match_dup 1) (match_dup 2)))])
(set (match_dup 0)
(if_then_else (eq:SI (reg:CC_NOOV CC_REGNUM) (const_int 0))
(match_dup 0)
(const_int 1)))]
""
)
;; Match the second half of *zero_extract_compare0_shifted
(define_insn "*movsi_conditional"
[(set (match_operand:SI 0 "s_register_operand" "=r")
(if_then_else (eq:SI (reg:CC_NOOV CC_REGNUM) (const_int 0))
(match_dup 0)
(match_operand:SI 1 "const_int_operand" "n")))]
"TARGET_ARM"
"movne\\t%0, %1"
[(set_attr "conds" "use")]
)
--
What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
2003-06-22 3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
2004-05-09 17:11 ` pb at gcc dot gnu dot org
@ 2004-05-17 11:27 ` rearnsha at gcc dot gnu dot org
2004-05-17 11:32 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-05-17 11:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-05-16 22:19 -------
The proposed patch isn't quite correct. There are already patterns that can be
used as the target of the split, so there's no need to add new ones, and the
split needs to
1) Convert operand2
2) Not apply to Thumb state
Patch forthcoming.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Component|rtl-optimization |target
Last reconfirmed|2004-01-01 07:59:12 |2004-05-16 22:19:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
` (2 preceding siblings ...)
2004-05-17 11:27 ` [Bug target/10982] " rearnsha at gcc dot gnu dot org
@ 2004-05-17 11:32 ` cvs-commit at gcc dot gnu dot org
2004-05-17 11:38 ` rearnsha at gcc dot gnu dot org
2004-05-17 11:40 ` rearnsha at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-05-17 11:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-05-16 22:22 -------
Subject: Bug 10982
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: rearnsha@gcc.gnu.org 2004-05-16 22:22:49
Modified files:
gcc : ChangeLog
gcc/config/arm : arm.md
Log message:
PR target/10982
* arm.md (ne_zeroextractsi): Convert to insn-and-split.
(ne_zeroextractsi_shifted): New pattern.
(ite_ne_zeroextractsi): New pattern.
(ite_ne_zeroextractsi_shifted): New pattern.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3669&r2=2.3670
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.md.diff?cvsroot=gcc&r1=1.167&r2=1.168
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
` (3 preceding siblings ...)
2004-05-17 11:32 ` cvs-commit at gcc dot gnu dot org
@ 2004-05-17 11:38 ` rearnsha at gcc dot gnu dot org
2004-05-17 11:40 ` rearnsha at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-05-17 11:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-05-16 22:23 -------
Fixed with applied patch
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/10982] [arm] poor optimisation of "if (var & const)"
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
` (4 preceding siblings ...)
2004-05-17 11:38 ` rearnsha at gcc dot gnu dot org
@ 2004-05-17 11:40 ` rearnsha at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-05-17 11:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-05-16 22:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
2003-06-22 3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
2004-05-09 17:11 ` pb at gcc dot gnu dot org
2004-05-17 11:27 ` [Bug target/10982] " rearnsha at gcc dot gnu dot org
2004-05-17 11:32 ` cvs-commit at gcc dot gnu dot org
2004-05-17 11:38 ` rearnsha at gcc dot gnu dot org
2004-05-17 11:40 ` rearnsha at gcc dot gnu dot 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).