[clang] [Clang] Fix incorrect handling of #pragma {GCC} unroll N in dependent context (PR #90240)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 26 11:22:21 PDT 2024


================
@@ -109,16 +109,20 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
     SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
   } else if (PragmaName == "unroll") {
     // #pragma unroll N
-    if (ValueExpr && !ValueExpr->isValueDependent()) {
-      llvm::APSInt ValueAPS;
-      ExprResult R = S.VerifyIntegerConstantExpression(ValueExpr, &ValueAPS);
-      assert(!R.isInvalid() && "unroll count value must be a valid value, it's "
-                               "should be checked in Sema::CheckLoopHintExpr");
-      (void)R;
-      // The values of 0 and 1 block any unrolling of the loop.
-      if (ValueAPS.isZero() || ValueAPS.isOne())
-        SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Disable);
-      else
+    if (ValueExpr) {
+      if (!ValueExpr->isValueDependent()) {
+        llvm::APSInt ValueAPS;
+        ExprResult R = S.VerifyIntegerConstantExpression(ValueExpr, &ValueAPS);
+        assert(!R.isInvalid() &&
+               "unroll count value must be a valid value, it's "
+               "should be checked in Sema::CheckLoopHintExpr");
+        (void)R;
----------------
erichkeane wrote:

Remove this.

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


More information about the cfe-commits mailing list