================
@@ -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;
----------------
dmpots wrote:

I think the `[unroll]` directive in hlsl does not map exactly to the 
`llvm.loop.unroll.count` metadata interpretation. One difference is that the 
`[unroll(N)]` will force the iteration count even if the loop bounds is 
actually larger. So if the loop has an upper bound of `10` and we write 
`[unroll(3)]` it will force the loop to only execute 3 times.

https://godbolt.org/z/bT3EdcMKs

I don't think the llvm unroll count metadata works the same way. Maybe we want 
to not support that behavior, but it seems like it is something we should 
document and maybe apply to HLSL202x if we intend to change the behavior.

https://github.com/llvm/llvm-project/pull/93879
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to