This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Changes for if-convert to recognize simple conditional reduction.
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Yuri Rumyantsev <ysrumyan at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Igor Zamyatin <izamyatin at gmail dot com>
- Date: Tue, 29 Apr 2014 11:14:00 +0200
- Subject: Re: Changes for if-convert to recognize simple conditional reduction.
- Authentication-results: sourceware.org; auth=none
- References: <CAEoMCqR1=M6rzTMjVLEpuK1HPdq=vyG_cCGSQy-wWiNmUecZFQ at mail dot gmail dot com> <535EB481 dot 2070300 at redhat dot com>
On Mon, Apr 28, 2014 at 10:05 PM, Richard Henderson <rth@redhat.com> wrote:
> On 04/17/2014 06:09 AM, Yuri Rumyantsev wrote:
>> + /* Build cond expression using COND and constant operand
>> + of reduction rhs. */
>> + c = fold_build_cond_expr (TREE_TYPE (rhs1),
>> + unshare_expr (cond),
>> + swap? zero: op1,
>> + swap? op1: zero);
>
> Do we recognize somewhere the canonical value for the comparison is -1, and
> simplify this further?
>
> E.g.
>
> if (A[i] != 0) num += 1;
>
> _vec_cmp = (_vec_A != _vec_ZERO);
> _vec_num -= _vec_cmp;
>
>
> if (A[i] != 0) num += x;
>
> _vec_cmp = (_vec_A != _vec_ZERO);
> _vec_cmp *= _vec_x;
> _vec_num -= _vec_cmp;
While the middle-end knows that vector comparisons result in
{0,0...} or {-1,-1,...} I doubt that anyone implemented the above
transform.
Note that it depends on the target on whether the transform
would be profitable - a target may only implement
a vector conditional move for example (the XOP vcond one).
So the correct place for the optimization would be the
expander or combine (unless we apply some canonicalization
rule on GIMPLE - but the back-transform is certainly more
complicated than optimally expanding vec_A != vec_ZERO ? 0 : 1)
Richard.
>
>
> r~