Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Richard Sandiford
Robin Dapp writes: > Thank you for the explanation. > > So, assuming I added an IFN_VCOND_MASK and IFN_VCOND_MASK_LEN along > with the respective helper and expand functions, what would be the > way forward? IMO it'd be worth starting with the _LEN form only. > Generate an IFN_VCOND_MASK(_LEN) h

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Richard Sandiford
Richard Biener writes: > On Mon, Oct 16, 2023 at 11:59 PM Richard Sandiford > wrote: >> >> Robin Dapp writes: >> >> Why are the contents of this if statement wrong for COND_LEN? >> >> If the "else" value doesn't matter, then the masked form can use >> >> the "then" value for all elements. I wou

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Robin Dapp
Thank you for the explanation. So, assuming I added an IFN_VCOND_MASK and IFN_VCOND_MASK_LEN along with the respective helper and expand functions, what would be the way forward? Generate an IFN_VCOND_MASK(_LEN) here instead of a VEC_COND_EXPR? How would I make sure all of match.pd's vec_cond opt

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Richard Sandiford
Robin Dapp writes: >>> I don't know much about valueisation either :) But it does feel >>> like we're working around the lack of a LEN form of COND_EXPR. >>> In other words, it seems odd that we can do: >>> >>> IFN_COND_LEN_ADD (mask, a, 0, b, len, bias) >>> >>> but we can't do: >>> >>> IFN_C

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Robin Dapp
>> I don't know much about valueisation either :) But it does feel >> like we're working around the lack of a LEN form of COND_EXPR. >> In other words, it seems odd that we can do: >> >> IFN_COND_LEN_ADD (mask, a, 0, b, len, bias) >> >> but we can't do: >> >> IFN_COND_LEN (mask, a, b, len, bia

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-17 Thread Richard Biener
On Mon, Oct 16, 2023 at 11:59 PM Richard Sandiford wrote: > > Robin Dapp writes: > >> Why are the contents of this if statement wrong for COND_LEN? > >> If the "else" value doesn't matter, then the masked form can use > >> the "then" value for all elements. I would have expected the same > >> th

[PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-16 Thread juzhe.zh...@rivai.ai
Hi, Richard. >> Does IFN_COND_LEN make conceptual sense on RVV? If so, would defining >> it solve some of these problems? Yes, IFN_COND_LEN make sense to RVV. We have vmerge instruction which depending on VL/AVL. I must say my internal RVV GCC has IFN_LEN_VCOND_MASK which simplify COND_LEN_ADD

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-16 Thread Richard Sandiford
Robin Dapp writes: >> Why are the contents of this if statement wrong for COND_LEN? >> If the "else" value doesn't matter, then the masked form can use >> the "then" value for all elements. I would have expected the same >> thing to be true of COND_LEN. > > Right, that one was overly pessimistic.

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-13 Thread Robin Dapp
> Why are the contents of this if statement wrong for COND_LEN? > If the "else" value doesn't matter, then the masked form can use > the "then" value for all elements. I would have expected the same > thing to be true of COND_LEN. Right, that one was overly pessimistic. Removed. > But isn't the

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-12 Thread Richard Sandiford
Richard Sandiford writes: > Robin Dapp via Gcc-patches writes: >> [...] >> @@ -386,9 +390,29 @@ try_conditional_simplification (internal_fn ifn, >> gimple_match_op *res_op, >> default: >>gcc_unreachable (); >> } >> - *res_op = cond_op; >> - maybe_resimplify_conditional_op (se

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-12 Thread Richard Sandiford
if they are unused. > > Bootstrapped and regtested on aarch64 and x86. Sorry for the slow review. I was hoping Richi would take it, but I see he was hoping the same from me. > Regards > Robin > > Subject: [PATCH v2] gimple-match: Do not try UNCOND optimization with > COND_LEN. > >

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-10-04 Thread Robin Dapp
Ping^2. I realize it's not very elegant as of now. If there's a better/shorter way to solve this feel free to suggest :) Regards Robin

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-09-18 Thread Robin Dapp via Gcc-patches
Ping. Regards Robin

gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-09-13 Thread juzhe.zh...@rivai.ai
Thanks Robin for fixing it. - : cond (cond_in), else_value (else_value_in) + : cond (cond_in), else_value (else_value_in), len (NULL_TREE), +bias (NULL_TREE)It seems that you shouldn't include this fix in the patch? + + if (len) +{ + /* If we had a COND_LEN before we need to ensure

Re: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-09-11 Thread Robin Dapp via Gcc-patches
Subject: [PATCH v2] gimple-match: Do not try UNCOND optimization with COND_LEN. On riscv we mis-optimize conditional (length) operations into unconditional operations e.g. in slp-reduc-7.c and gcc.dg/pr92301.c. This patch prevents optimizing e.g. COND_LEN_ADD ({-1, ... }, a, 0, c, len, bias

[PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN.

2023-09-08 Thread Robin Dapp via Gcc-patches
Hi, found in slp-reduc-7.c, this patch prevents optimizing e.g. COND_LEN_ADD ({-1, ... }, a, 0, c, len, bias) unconditionally into just "a". Currently, we assume that COND_LEN operations can be optimized similarly to COND operations. As the length is part of the mask (and usually not compile-ti