public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/94543] New: missed optimization with MIN and AND with type promotion
@ 2020-04-09 19:13 rth at gcc dot gnu.org
2020-04-14 6:44 ` [Bug rtl-optimization/94543] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: rth at gcc dot gnu.org @ 2020-04-09 19:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94543
Bug ID: 94543
Summary: missed optimization with MIN and AND with type
promotion
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: rth at gcc dot gnu.org
Target Milestone: ---
unsigned f(unsigned short x) { return (x > 0xff ? 0xff : x) & 0xff; }
cmpw $255, %di
movl $255, %eax
cmova %eax, %edi
movzwl %di, %eax
ret
The final AND is of course redundant. The optimizer removes it
for wider types, but fails to do so when promoting from short.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug rtl-optimization/94543] missed optimization with MIN and AND with type promotion
2020-04-09 19:13 [Bug middle-end/94543] New: missed optimization with MIN and AND with type promotion rth at gcc dot gnu.org
@ 2020-04-14 6:44 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-14 6:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94543
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Version|tree-ssa |10.0
Last reconfirmed| |2020-04-14
Status|UNCONFIRMED |NEW
Target| |x86_64-*-* i?86-*-*
Keywords| |missed-optimization
Component|middle-end |rtl-optimization
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that we fail to have a proper representation of the target on the
GIMPLE level. We expand to RTL from the optimal
<bb 2> [local count: 1073741824]:
# RANGE [0, 255] NONZERO 255
_1 = MIN_EXPR <x_2(D), 255>;
# RANGE [0, 255] NONZERO 255
_3 = (unsigned int) _1;
return _3;
but that produces
(insn 10 6 9 (set (reg:HI 88)
(const_int 255 [0xff])) "x.c":1:56 -1
(nil))
(insn 9 10 11 (set (reg:CC 17 flags)
(compare:CC (reg/v:HI 84 [ x ])
(const_int 255 [0xff]))) "x.c":1:56 -1
(nil))
(insn 11 9 12 (set (reg:HI 87)
(if_then_else:HI (leu (reg:CC 17 flags)
(const_int 0 [0]))
(reg/v:HI 84 [ x ])
(reg:HI 88))) "x.c":1:56 -1
(nil))
(insn 12 11 13 (set (reg:SI 86)
(zero_extend:SI (reg:HI 87))) "x.c":1:61 -1
(nil))
given fort the (unsigned int) _1 zero-extension we don't have any other
representation on GIMPLE to elide the zero-extension. I'm also not
sure if (subreg:SI (reg:HI 87)) would be correct in all cases.
Marking rtl-optimization but eventually it's also a target issue.
We also don't have anything like a reg-note to tell ranges of a
set? Anyway, even on RTL the range of reg:HI 87 is clearly visible.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-14 6:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 19:13 [Bug middle-end/94543] New: missed optimization with MIN and AND with type promotion rth at gcc dot gnu.org
2020-04-14 6:44 ` [Bug rtl-optimization/94543] " rguenth 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).