[clang] [HLSL] add loop unroll (PR #93879)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 12:19:30 PDT 2024


================
@@ -635,6 +635,17 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx,
         Option = LoopHintAttr::UnrollCount;
         State = LoopHintAttr::Numeric;
       }
+    } else if (HLSLLoopHint) {
+      ValueInt = HLSLLoopHint->getDirective();
+      if (HLSLLoopHint->getSemanticSpelling() ==
+          HLSLLoopHintAttr::Spelling::Microsoft_unroll) {
+        if (ValueInt == 0)
+          State = LoopHintAttr::Enable;
+        if (ValueInt > 0) {
+          Option = LoopHintAttr::UnrollCount;
----------------
tex3d wrote:

You should think of the HLSL argument as manually specifying the maximum iterations for the loop.

https://github.com/llvm/llvm-project/pull/93879


More information about the cfe-commits mailing list