public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/27469] New: zero extension not eliminated
@ 2006-05-07 9:17 falk at debian dot org
2006-05-07 18:59 ` [Bug rtl-optimization/27469] " pinskia at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: falk at debian dot org @ 2006-05-07 9:17 UTC (permalink / raw)
To: gcc-bugs
unsigned parity(unsigned x) {
x ^= x >> 16;
x ^= x >> 8;
x ^= x >> 4;
x &= 0xf;
return (0x6996 >> x) & 1;
}
gcc 4.2.0 20060506 produces:
extwl a0,0x2,t2
lda v0,27030
xor t2,a0,t2
zapnot t2,0xf,t1 # redundant zero-extension
srl t1,0x8,t1
xor t1,t2,t1
zapnot t1,0xf,t0 # redundant zero-extension
srl t0,0x4,t0
xor t0,t1,t0
and t0,0xf,t0
sra v0,t0,v0
and v0,0x1,v0
-fsee doesn't change anything here.
--
Summary: zero extension not eliminated
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: falk at debian dot org
GCC build triplet: alphaev68-unknown-linux-gnu
GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/27469] zero extension not eliminated
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
@ 2006-05-07 18:59 ` pinskia at gcc dot gnu dot org
2009-04-18 15:25 ` mattst88 at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-07 18:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-05-07 18:59 -------
Confirmed.
It does try to do it:
(insn 18 16 19 2 (set (reg:DI 79 [ x.25 ])
(zero_extend:DI (subreg/s:SI (reg/v:DI 71 [ x.25 ]) 0))) 52
{zero_extendsidi2} (insn_list:REG_DEP_TRUE 16 (nil))
(nil))
into;
(insn 56 16 54 2 (set (subreg:SI (reg:DI 79 [ x.25 ]) 0)
(subreg/s:SI (reg/v:DI 71 [ x.25 ]) 0)) -1 (nil)
(nil))
(insn 54 56 19 2 (set (reg:DI 79 [ x.25 ])
(zero_extend:DI (subreg:SI (reg:DI 79 [ x.25 ]) 0))) 52
{zero_extendsidi2} (nil)
(nil))
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-05-07 18:59:35
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/27469] zero extension not eliminated
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
2006-05-07 18:59 ` [Bug rtl-optimization/27469] " pinskia at gcc dot gnu dot org
@ 2009-04-18 15:25 ` mattst88 at gmail dot com
2009-11-29 16:52 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mattst88 at gmail dot com @ 2009-04-18 15:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from mattst88 at gmail dot com 2009-04-18 15:25 -------
(In reply to comment #0)
> unsigned parity(unsigned x) {
> x ^= x >> 16;
> x ^= x >> 8;
> x ^= x >> 4;
> x &= 0xf;
> return (0x6996 >> x) & 1;
> }
>
> gcc 4.2.0 20060506 produces:
> extwl a0,0x2,t2
> lda v0,27030
> xor t2,a0,t2
> zapnot t2,0xf,t1 # redundant zero-extension
> srl t1,0x8,t1
> xor t1,t2,t1
> zapnot t1,0xf,t0 # redundant zero-extension
> srl t0,0x4,t0
> xor t0,t1,t0
> and t0,0xf,t0
> sra v0,t0,v0
> and v0,0x1,v0
>
> -fsee doesn't change anything here.
>
Compaq C generates:
0000000000000000 <parity>:
0: 82 16 02 4a srl a0,0x10,t1
4: 96 69 bf 20 lda t4,27030
8: 02 08 02 46 xor a0,t1,t1
c: 83 16 41 48 srl t1,0x8,t2
10: 02 08 43 44 xor t1,t2,t1
14: 84 96 40 48 srl t1,0x4,t3
18: 02 08 44 44 xor t1,t3,t1
1c: 02 f0 41 44 and t1,0xf,t1
20: 82 07 a2 48 sra t4,t1,t1
24: 00 30 40 44 and t1,0x1,v0
28: 01 80 fa 6b ret
--
mattst88 at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mattst88 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/27469] zero extension not eliminated
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
2006-05-07 18:59 ` [Bug rtl-optimization/27469] " pinskia at gcc dot gnu dot org
2009-04-18 15:25 ` mattst88 at gmail dot com
@ 2009-11-29 16:52 ` rguenth at gcc dot gnu dot org
2009-12-03 0:32 ` rth at gcc dot gnu dot org
2009-12-08 0:55 ` rth at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-29 16:52 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/27469] zero extension not eliminated
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
` (2 preceding siblings ...)
2009-11-29 16:52 ` rguenth at gcc dot gnu dot org
@ 2009-12-03 0:32 ` rth at gcc dot gnu dot org
2009-12-08 0:55 ` rth at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rth at gcc dot gnu dot org @ 2009-12-03 0:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rth at gcc dot gnu dot org 2009-12-03 00:32 -------
Gcc 4.5 has regressed this even further:
extwl $16,2,$1
xor $1,$16,$16
addl $31,$16,$16 << signextend
zapnot $16,15,$1 << zeroextend of signextend
srl $1,8,$1
Neither extension is needed, of course.
--
rth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2006-05-07 18:59:35 |2009-12-03 00:32:32
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/27469] zero extension not eliminated
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
` (3 preceding siblings ...)
2009-12-03 0:32 ` rth at gcc dot gnu dot org
@ 2009-12-08 0:55 ` rth at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rth at gcc dot gnu dot org @ 2009-12-08 0:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rth at gcc dot gnu dot org 2009-12-08 00:55 -------
4.5 regression fixed in pr42269.
I don't know that we'll ever be able to fix the original PR.
The problem is that we need to work backward from the "x &= 0xf"
through the xor, and see that the srl doesn't actually use the
garbage high bits that the srl might have shifted in. And then
again back to the first srl.
Combine can't handle this because there are 4 insns involved,
and it only ever handles merging 3 at a time. So we'd need some
sort of new pass that would be able to see these extensions are
unneeded.
--
rth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-08 0:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-07 9:17 [Bug tree-optimization/27469] New: zero extension not eliminated falk at debian dot org
2006-05-07 18:59 ` [Bug rtl-optimization/27469] " pinskia at gcc dot gnu dot org
2009-04-18 15:25 ` mattst88 at gmail dot com
2009-11-29 16:52 ` rguenth at gcc dot gnu dot org
2009-12-03 0:32 ` rth at gcc dot gnu dot org
2009-12-08 0:55 ` rth 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).