This is the mail archive of the
mailing list for the GCC project.
Re: [Patch] Cleanup widest_int_mode_for_size
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: James Greenhalgh <james dot greenhalgh at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 31 Oct 2014 11:56:45 +0100
- Subject: Re: [Patch] Cleanup widest_int_mode_for_size
- Authentication-results: sourceware.org; auth=none
- References: <1411463841-29861-1-git-send-email-james dot greenhalgh at arm dot com>
On Tue, Sep 23, 2014 at 11:17 AM, James Greenhalgh
> The comment on widest_int_mode_for_size claims that it returns the
> widest integer mode no wider than size. The implementation looks more
> like it finds the widest integer mode smaller than size. Everywhere it
> is used, the mode it is looking for is ultimately checked against an
> expected alignment or is used for heuristics that should be thinking
> about that check, so pull it in to here.
> Throughout expr.c corrections are made for this fact - adding one to
> the size passed to this function. This feels a bit backwards to me.
> This patch fixes that, and then fixes the fallout throughout expr.c.
> Generally, this means simplifying a bunch of move_by_pieces style copy
> Bootstrapped on x86_64, arm and AArch64 with no issues.
I suppose you verified the generated code is the same?
Btw, this all looks more like this wants to be an iterator-style approach,
iterating over modes from larger to narrower that honor the alignment.
Repeatedly iterating over all modes in the loops iterating towards
smaller modes looks backward. Iterating by asking for size - 1
in the next round isn't much clearer than asking for size + 1 either.
> OK for trunk?
So I'm not sure this is a real improvement. Instead changing the loops
to explicitely iterate via GET_MODE_NARROWER_MODE (oops - we don't
have that, but it should be easy to add) would be better.
> 2014-09-23 James Greenhalgh <email@example.com>
> * expr.c (MOVE_BY_PIECES_P): Remove off-by-one correction to
> (CLEAR_BY_PIECES_P): Likewise.
> (SET_BY_PIECES_P): Likewise.
> (STORE_BY_PIECES_P): Likwise.
> (widest_int_mode_for_size): Return the widest mode in which the
> given size fits.
> (move_by_pieces): Remove off-by-one correction for max_size,
> simplify copy loop body.
> (move_by_pieces_ninsns): Simplify copy body.
> (can_store_by_pieces): Remove off-by-one correction for max_size,
> simplify copy body.
> (store_by_pieces_1): Likewise.