* [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code @ 2023-11-30 3:47 juzhe.zhong 2023-11-30 10:39 ` Tamar Christina 0 siblings, 1 reply; 4+ messages in thread From: juzhe.zhong @ 2023-11-30 3:47 UTC (permalink / raw) To: gcc-patches; +Cc: Richard Biener, tamar.christina [-- Attachment #1: Type: text/plain, Size: 1319 bytes --] Hi, Richard and Tamar. I am sorry for bothering you. Hope you don't mind I give some comments: Can we support partial vector for length ? IMHO, we can do that as follows: bool length_loop_p = LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo); if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) { if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype, OPTIMIZE_FOR_SPEED)) vect_record_loop_len (loop_vinfo, lens, ncopies, vectype, 1); else vect_record_loop_mask (loop_vinfo, masks, ncopies, truth_type, NULL); } if (length_loop_p) { tree len = vect_get_loop_len (loop_vinfo, gsi, loop_lens, 1, vectype, 0, 0); /* Use VCOND_MASK_LEN (all true, cond, all false, len, bias) to generate final mask = i < len + bias ? cond[i] : false. */ cond = gimple_build (&cond_gsi, IFN_VCOND_MASK_LEN, truth_type, all true mask, cond, all false mask, len, bias); } else if (masked_loop_p) { tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, truth_type, 0); cond = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), mask, cond, &cond_gsi); } This is a prototype. Is this idea reasonable to Richi ? Thanks. juzhe.zhong@rivai.ai ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code 2023-11-30 3:47 [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code juzhe.zhong @ 2023-11-30 10:39 ` Tamar Christina 2023-11-30 10:48 ` juzhe.zhong 0 siblings, 1 reply; 4+ messages in thread From: Tamar Christina @ 2023-11-30 10:39 UTC (permalink / raw) To: juzhe.zhong, gcc-patches; +Cc: Richard Biener [-- Attachment #1: Type: text/plain, Size: 2114 bytes --] Hi Juzhe, I'm happy to take the hunks, just that I can't test it and don't know the specifics of how it lens work. I still need to read up on it. I tried adding that chunk in, but for the first bit `lens` seems undefined, and the second bit it seems `bias` is undefined. I'll also need what to do for vectorizable_live_operations how to get the first element rather than the last. Thanks, Tamar From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai> Sent: Thursday, November 30, 2023 4:48 AM To: gcc-patches <gcc-patches@gcc.gnu.org> Cc: Richard Biener <richard.guenther@gmail.com>; Tamar Christina <Tamar.Christina@arm.com> Subject: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Hi, Richard and Tamar. I am sorry for bothering you. Hope you don't mind I give some comments: Can we support partial vector for length ? IMHO, we can do that as follows: bool length_loop_p = LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo); if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) { if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype, OPTIMIZE_FOR_SPEED)) vect_record_loop_len (loop_vinfo, lens, ncopies, vectype, 1); else vect_record_loop_mask (loop_vinfo, masks, ncopies, truth_type, NULL); } if (length_loop_p) { tree len = vect_get_loop_len (loop_vinfo, gsi, loop_lens, 1, vectype, 0, 0); /* Use VCOND_MASK_LEN (all true, cond, all false, len, bias) to generate final mask = i < len + bias ? cond[i] : false. */ cond = gimple_build (&cond_gsi, IFN_VCOND_MASK_LEN, truth_type, all true mask, cond, all false mask, len, bias); } else if (masked_loop_p) { tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, truth_type, 0); cond = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), mask, cond, &cond_gsi); } This is a prototype. Is this idea reasonable to Richi ? Thanks. ________________________________ juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code 2023-11-30 10:39 ` Tamar Christina @ 2023-11-30 10:48 ` juzhe.zhong 2023-11-30 10:58 ` Tamar Christina 0 siblings, 1 reply; 4+ messages in thread From: juzhe.zhong @ 2023-11-30 10:48 UTC (permalink / raw) To: tamar.christina, gcc-patches; +Cc: Richard Biener [-- Attachment #1: Type: text/plain, Size: 3173 bytes --] Thanks Tamar. I am not sure whether I am not on the same page with you. IMHO, ARM SVE will use the final mask = loop mask (generate by WHILE_ULT) & conditional mask. Use that final mask to do the cbranch. Am I right ? If yes, I leverage that for length and avoid too much codes change in your patch. So, for RVV, the length is pretty same as loop mask in ARM SVE. For example, suppose n = 4, in ARM SVE, WHILE_ULT (whilelo) generate mask = 0b11110000000.... Then use that mask to control the operations. For RVV, is the same, length will be 4, then we will only process the elements with index < 4. For bias, I think that won't be the issue. Currently, BIAS is not used by RVV and only used on len_load/len_store for IBM targets. So, the bias value by default is 0 in all other situations except len_load/len_store specifically for IBM. juzhe.zhong@rivai.ai From: Tamar Christina Date: 2023-11-30 18:39 To: juzhe.zhong@rivai.ai; gcc-patches CC: Richard Biener Subject: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Hi Juzhe, I’m happy to take the hunks, just that I can’t test it and don’t know the specifics of how it lens work. I still need to read up on it. I tried adding that chunk in, but for the first bit `lens` seems undefined, and the second bit it seems `bias` is undefined. I’ll also need what to do for vectorizable_live_operations how to get the first element rather than the last. Thanks, Tamar From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai> Sent: Thursday, November 30, 2023 4:48 AM To: gcc-patches <gcc-patches@gcc.gnu.org> Cc: Richard Biener <richard.guenther@gmail.com>; Tamar Christina <Tamar.Christina@arm.com> Subject: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Hi, Richard and Tamar. I am sorry for bothering you. Hope you don't mind I give some comments: Can we support partial vector for length ? IMHO, we can do that as follows: bool length_loop_p = LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo); if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) { if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype, OPTIMIZE_FOR_SPEED)) vect_record_loop_len (loop_vinfo, lens, ncopies, vectype, 1); else vect_record_loop_mask (loop_vinfo, masks, ncopies, truth_type, NULL); } if (length_loop_p) { tree len = vect_get_loop_len (loop_vinfo, gsi, loop_lens, 1, vectype, 0, 0); /* Use VCOND_MASK_LEN (all true, cond, all false, len, bias) to generate final mask = i < len + bias ? cond[i] : false. */ cond = gimple_build (&cond_gsi, IFN_VCOND_MASK_LEN, truth_type, all true mask, cond, all false mask, len, bias); } else if (masked_loop_p) { tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, truth_type, 0); cond = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), mask, cond, &cond_gsi); } This is a prototype. Is this idea reasonable to Richi ? Thanks. juzhe.zhong@rivai.ai ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code 2023-11-30 10:48 ` juzhe.zhong @ 2023-11-30 10:58 ` Tamar Christina 0 siblings, 0 replies; 4+ messages in thread From: Tamar Christina @ 2023-11-30 10:58 UTC (permalink / raw) To: juzhe.zhong, gcc-patches; +Cc: Richard Biener [-- Attachment #1: Type: text/plain, Size: 4417 bytes --] Hi Juzhe, I meant that “lens” is undefined, from looking around I guess that needs to be vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo); for `bias` I meant cond = gimple_build (&cond_gsi, IFN_VCOND_MASK_LEN, truth_type, all true mask, cond, all false mask, len, bias); that variable `bias` isn’t defined. And I can’t find any other usage of IFN_VCOND_MASK_LEN creation to figure out what it’s supposed to be 😊 is it just an SImode 0? Thanks, Tamar From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai> Sent: Thursday, November 30, 2023 11:49 AM To: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches <gcc-patches@gcc.gnu.org> Cc: Richard Biener <richard.guenther@gmail.com> Subject: Re: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Thanks Tamar. I am not sure whether I am not on the same page with you. IMHO, ARM SVE will use the final mask = loop mask (generate by WHILE_ULT) & conditional mask. Use that final mask to do the cbranch. Am I right ? If yes, I leverage that for length and avoid too much codes change in your patch. So, for RVV, the length is pretty same as loop mask in ARM SVE. For example, suppose n = 4, in ARM SVE, WHILE_ULT (whilelo) generate mask = 0b11110000000.... Then use that mask to control the operations. For RVV, is the same, length will be 4, then we will only process the elements with index < 4. For bias, I think that won't be the issue. Currently, BIAS is not used by RVV and only used on len_load/len_store for IBM targets. So, the bias value by default is 0 in all other situations except len_load/len_store specifically for IBM. ________________________________ juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai> From: Tamar Christina<mailto:Tamar.Christina@arm.com> Date: 2023-11-30 18:39 To: juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai>; gcc-patches<mailto:gcc-patches@gcc.gnu.org> CC: Richard Biener<mailto:richard.guenther@gmail.com> Subject: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Hi Juzhe, I’m happy to take the hunks, just that I can’t test it and don’t know the specifics of how it lens work. I still need to read up on it. I tried adding that chunk in, but for the first bit `lens` seems undefined, and the second bit it seems `bias` is undefined. I’ll also need what to do for vectorizable_live_operations how to get the first element rather than the last. Thanks, Tamar From: juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai> <juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai>> Sent: Thursday, November 30, 2023 4:48 AM To: gcc-patches <gcc-patches@gcc.gnu.org<mailto:gcc-patches@gcc.gnu.org>> Cc: Richard Biener <richard.guenther@gmail.com<mailto:richard.guenther@gmail.com>>; Tamar Christina <Tamar.Christina@arm.com<mailto:Tamar.Christina@arm.com>> Subject: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Hi, Richard and Tamar. I am sorry for bothering you. Hope you don't mind I give some comments: Can we support partial vector for length ? IMHO, we can do that as follows: bool length_loop_p = LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo); if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) { if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype, OPTIMIZE_FOR_SPEED)) vect_record_loop_len (loop_vinfo, lens, ncopies, vectype, 1); else vect_record_loop_mask (loop_vinfo, masks, ncopies, truth_type, NULL); } if (length_loop_p) { tree len = vect_get_loop_len (loop_vinfo, gsi, loop_lens, 1, vectype, 0, 0); /* Use VCOND_MASK_LEN (all true, cond, all false, len, bias) to generate final mask = i < len + bias ? cond[i] : false. */ cond = gimple_build (&cond_gsi, IFN_VCOND_MASK_LEN, truth_type, all true mask, cond, all false mask, len, bias); } else if (masked_loop_p) { tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, truth_type, 0); cond = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), mask, cond, &cond_gsi); } This is a prototype. Is this idea reasonable to Richi ? Thanks. ________________________________ juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-30 10:58 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-30 3:47 [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code juzhe.zhong 2023-11-30 10:39 ` Tamar Christina 2023-11-30 10:48 ` juzhe.zhong 2023-11-30 10:58 ` Tamar Christina
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).