Lukas Sommer via llvm-dev
2020-Dec-21 20:36 UTC
[llvm-dev] Vectorization of math function failed?
Hi Venkat., thanks for adding the support for libmvec! Is there a pass or something similar to replace calls to intrinsics that already operate on vector operands with calls to libmvec? inject-tli-mappings seems to add the attributes only to scalar calls to intrinsics such as llvm.exp and the loop-vectorizer then might vectorize these calls. In my use case, I'm getting vectorized calls to LLVM intrinsics from MLIR and would like to replace those with calls to libmvec, but as the code is already vectorized, the LoopVectorizer does not do these replacements. So for example, in the LLVM IR generated from MLIR, there is a call such as: %103 = fmul <4 x double> %102, <double -5.000000e-01, double -5.000000e-01, double -5.000000e-01, double -5.000000e-01> %104 = tail call <4 x double> @llvm.exp.v4f64(<4 x double> %103) I would like to have a pass replace the call to llvm.exp.v4f64 with a call @_ZGVdN4v_exp(<4 x double>), whose declaration is inserted by inject-tli-mappings. Are you aware of such a pass or another way to achieve this behavior? Thanks in advance, Lukas Lukas Sommer, M.Sc. TU Darmstadt Embedded Systems and Applications Group (ESA) Hochschulstr. 10, 64289 Darmstadt, Germany Phone: +49 6151 1622429 www.esa.informatik.tu-darmstadt.de On 23.09.20 17:11, Venkataramanan Kumar via llvm-dev wrote:> > Hi Florian and Alexandre, > > On Tue, 15 Sep 2020 at 19:30, Alexandre Bique > <bique.alexandre at gmail.com <mailto:bique.alexandre at gmail.com>> wrote: > > On Tue, Sep 15, 2020 at 3:58 PM Venkataramanan Kumar > <venkataramanan.kumar.llvm at gmail.com > <mailto:venkataramanan.kumar.llvm at gmail.com>> wrote: > > I have not yet started the patch work. > > > > Collected information about the ABI for the routines. To start > with I am thinking of supporting pow/lib/exp/sin/cos/log routines > till VF 8 which are non masked variants in the initial patch. > > I will try to send the patch early next week. > > Great, let me know if you need help or don't have time to look at it. > > > I made a patch and submitted it here. > https://reviews.llvm.org/D88154 > > regards, > venkat. > > > > Regards, > Alexandre > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201221/5a5504bd/attachment.html>
Venkataramanan Kumar via llvm-dev
2020-Dec-22 11:51 UTC
[llvm-dev] Vectorization of math function failed?
Hi Lukas, + Florian and Sanjay. On Tue, 22 Dec 2020 at 02:06, Lukas Sommer <sommer at esa.tu-darmstadt.de> wrote:> Hi Venkat., > > thanks for adding the support for libmvec! > > Is there a pass or something similar to replace calls to intrinsics that > already operate on vector operands with calls to libmvec? >I am not aware of any existing pass.> inject-tli-mappings seems to add the attributes only to scalar calls to > intrinsics such as llvm.exp and the loop-vectorizer then might vectorize > these calls. > > In my use case, I'm getting vectorized calls to LLVM intrinsics from MLIR > and would like to replace those with calls to libmvec, but as the code is > already vectorized, the LoopVectorizer does not do these replacements. > > So for example, in the LLVM IR generated from MLIR, there is a call such > as: > > %103 = fmul <4 x double> %102, <double -5.000000e-01, double > -5.000000e-01, double -5.000000e-01, double -5.000000e-01> > %104 = tail call <4 x double> @llvm.exp.v4f64(<4 x double> %103) > > I would like to have a pass replace the call to llvm.exp.v4f64 with a call > @_ZGVdN4v_exp(<4 x double>), whose declaration is inserted by > inject-tli-mappings. > > Are you aware of such a pass or another way to achieve this behavior? >May be we should have one IR pass which does this conversion or make the code gen lower it to the required call. I have added few others to comment. regards, Venkat.> Thanks in advance, > > Lukas > > Lukas Sommer, M.Sc. > TU Darmstadt > Embedded Systems and Applications Group (ESA) > Hochschulstr. 10, 64289 Darmstadt, Germany > Phone: +49 6151 1622429www.esa.informatik.tu-darmstadt.de > > On 23.09.20 17:11, Venkataramanan Kumar via llvm-dev wrote: > > > Hi Florian and Alexandre, > > On Tue, 15 Sep 2020 at 19:30, Alexandre Bique <bique.alexandre at gmail.com> > wrote: > >> On Tue, Sep 15, 2020 at 3:58 PM Venkataramanan Kumar >> <venkataramanan.kumar.llvm at gmail.com> wrote: >> > I have not yet started the patch work. >> > >> > Collected information about the ABI for the routines. To start with I >> am thinking of supporting pow/lib/exp/sin/cos/log routines till VF 8 which >> are non masked variants in the initial patch. >> > I will try to send the patch early next week. >> >> Great, let me know if you need help or don't have time to look at it. >> > > I made a patch and submitted it here. > https://reviews.llvm.org/D88154 > > regards, > venkat. > > >> >> Regards, >> Alexandre >> > > _______________________________________________ > LLVM Developers mailing listllvm-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201222/08f313a8/attachment.html>
Lukas Sommer via llvm-dev
2021-Jan-25 17:26 UTC
[llvm-dev] Vectorization of math function failed?
Hi Venkat., thanks for your reply and sorry for the long delay. I went ahead and implemented a pass that performs this transformation as an IR pass: https://reviews.llvm.org/D95373 It would be great if some of you could review that patch and provide feedback. Thanks in advance, Best Lukas Lukas Sommer, M.Sc. TU Darmstadt Embedded Systems and Applications Group (ESA) Hochschulstr. 10, 64289 Darmstadt, Germany Phone: +49 6151 1622429 www.esa.informatik.tu-darmstadt.de On 22.12.20 12:51, Venkataramanan Kumar wrote:> Hi Lukas, > > + Florian and Sanjay. > > On Tue, 22 Dec 2020 at 02:06, Lukas Sommer <sommer at esa.tu-darmstadt.de > <mailto:sommer at esa.tu-darmstadt.de>> wrote: > > Hi Venkat., > > thanks for adding the support for libmvec! > > Is there a pass or something similar to replace calls to > intrinsics that already operate on vector operands with calls to > libmvec? > > I am not aware of any existing pass. > > inject-tli-mappings seems to add the attributes only to scalar > calls to intrinsics such as llvm.exp and the loop-vectorizer then > might vectorize these calls. > > In my use case, I'm getting vectorized calls to LLVM intrinsics > from MLIR and would like to replace those with calls to libmvec, > but as the code is already vectorized, the LoopVectorizer does not > do these replacements. > > So for example, in the LLVM IR generated from MLIR, there is a > call such as: > > %103 = fmul <4 x double> %102, <double -5.000000e-01, double > -5.000000e-01, double -5.000000e-01, double -5.000000e-01> > %104 = tail call <4 x double> @llvm.exp.v4f64(<4 x double> %103) > > I would like to have a pass replace the call to llvm.exp.v4f64 > with a call @_ZGVdN4v_exp(<4 x double>), whose declaration is > inserted by inject-tli-mappings. > > Are you aware of such a pass or another way to achieve this behavior? > > May be we should have one IR pass which does this conversion or make > the code gen lower it to the required call. > I have added few others to comment. > > regards, > Venkat. > > Thanks in advance, > > Lukas > > Lukas Sommer, M.Sc. > TU Darmstadt > Embedded Systems and Applications Group (ESA) > Hochschulstr. 10, 64289 Darmstadt, Germany > Phone: +49 6151 1622429 > www.esa.informatik.tu-darmstadt.de <http://www.esa.informatik.tu-darmstadt.de> > > On 23.09.20 17:11, Venkataramanan Kumar via llvm-dev wrote: >> >> Hi Florian and Alexandre, >> >> On Tue, 15 Sep 2020 at 19:30, Alexandre Bique >> <bique.alexandre at gmail.com <mailto:bique.alexandre at gmail.com>> wrote: >> >> On Tue, Sep 15, 2020 at 3:58 PM Venkataramanan Kumar >> <venkataramanan.kumar.llvm at gmail.com >> <mailto:venkataramanan.kumar.llvm at gmail.com>> wrote: >> > I have not yet started the patch work. >> > >> > Collected information about the ABI for the routines. To >> start with I am thinking of supporting >> pow/lib/exp/sin/cos/log routines till VF 8 which are non >> masked variants in the initial patch. >> > I will try to send the patch early next week. >> >> Great, let me know if you need help or don't have time to >> look at it. >> >> >> I made a patch and submitted it here. >> https://reviews.llvm.org/D88154 >> >> regards, >> venkat. >> >> >> >> Regards, >> Alexandre >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210125/8cb431f9/attachment.html>