<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Sjoerd,<div class=""><br class=""></div><div class="">Thanks for writing this up! As Philip already mentioned, I think clang should handle enabling transforms by setting the corresponding `enable` metadata when more specific transform pragmas are used. This is what the expected behavior is according to the docs and the current implementation leads to surprising outcomes like in PR<span class="">27643</span><span class="">.</span></div><div class=""><br class=""></div><div class="">We probably should also enable required transformations like loop rotation when vectorization was requested via a pragma, as LoopVectorize requires rotated loops. Adam put up a patch for that a while ago <a href="https://reviews.llvm.org/D59832" class="">https://reviews.llvm.org/D59832</a>.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Florian</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Aug 7, 2019, at 08:25, Sjoerd Meijer via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><span class="">We have recently added support for a new loop pragma 'vectorize_predicate' [1].<br class=""></span><div class="">During review of the LLVM part that does the actual transformation [2], the<br class=""></div><div class="">question was raised if 'vectorize_predicate' should imply 'vectorize(enable)'.<br class=""></div><div class="">I agree that this is indeed what users would most likely expect and so I<br class=""></div><div class="">created a patch for that [3].<br class=""></div><div class=""><br class=""></div><div class="">During review of [3], Florian mentioned bug report [4] supporting the case that<br class=""></div><div class="">users indeed expect that more specific pragmas such as e.g. vectorize_width(4)<br class=""></div><div class="">should imply vectorize(enable), but this is currently not the case. But our<br class=""></div><div class="">docs for example mention: "The following example implicitly enables<br class=""></div><div class="">vectorization and interleaving by specifying a vector width and interleaving<br class=""></div><div class="">count", and so we have an inconsistency in the docs and implementation. But as<br class=""></div><div class="">I have e.g. no clue what the behaviour could be of "vectorize(disable)<br class=""></div><div class="">vectorize_predicate(enable)", I would say the docs are right and the<br class=""></div><div class="">implementation is wrong.<br class=""></div><div class=""><br class=""></div><div class="">Michael mentioned that the situation with for example loop unroll pragmas<br class=""></div><div class="">'unroll(enable) unroll_count(4)' is not very different. Pragma 'unroll_count'<br class=""></div><div class="">also does not set 'llvm.loop.unroll.enable', but it is handled by the<br class=""></div><div class="">LoopUnroll pass itself and so we end up with checks like this:<br class=""></div><div class=""><br class=""></div><div class=""> bool ExplicitUnroll = PragmaCount > 0 || PragmaFullUnroll ||<br class=""></div><div class=""> PragmaEnableUnroll || UserUnrollCount;<br class=""></div><div class=""><br class=""></div><div class="">And again, this is very similar to 'vectorize_width', and we have different<br class=""></div><div class="">checks to see if vectorization is enabled.<br class=""></div><div class=""><br class=""></div><div class="">Because of the many inconsistencies, we came to the conclusion in [3] that we<br class=""></div><div class="">don't know how know how to (best) implement that setting an transformation<br class=""></div><div class="">option implies setting the transformation.<br class=""></div><div class=""><br class=""></div><div class="">My proposal would be that the transformation options imply the transformations<br class=""></div><div class="">by setting the enable flag of that transformation. Thus, vectorize options<br class=""></div><div class="">vectorize_width, vectorize_predicate, etc., set vectorize(enable), and unroll<br class=""></div><div class="">option unroll count set unroll(enable).<br class=""></div><div class=""><br class=""></div><div class="">Any thoughts on this welcome.<br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">[1]<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/rL366989" class="">https://reviews.llvm.org/rL366989</a><br class=""></div><div class="">[2]<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D65197" class="">https://reviews.llvm.org/D65197</a><br class=""></div><div class="">[3]<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D65776" class="">https://reviews.llvm.org/D65776</a><br class=""></div><span class="">[4]<span class="Apple-converted-space"> </span><a href="https://bugs.llvm.org/show_bug.cgi?id=27643" id="LPlnk126071" class="">https://bugs.llvm.org/show_bug.cgi?id=27643</a></span><br class=""></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">cfe-dev mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:cfe-dev@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">cfe-dev@lists.llvm.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></div></blockquote></div><br class=""></div></div></div></body></html>