llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We were not doing the final Neg here.

---
Full diff: https://github.com/llvm/llvm-project/pull/102302.diff


2 Files Affected:

- (modified) clang/lib/AST/Interp/Compiler.cpp (+11-5) 
- (modified) clang/test/AST/Interp/vectors.cpp (+11) 


``````````diff
diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 02cbe38f5fb1fa..acda6f29fb0f88 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -480,19 +480,25 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) 
{
       }
     }
 
+    auto maybeNegate = [&]() -> bool {
+      if (CE->getCastKind() == CK_BooleanToSignedIntegral)
+        return this->emitNeg(*ToT, CE);
+      return true;
+    };
+
     if (ToT == PT_IntAP)
-      return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+      return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+             maybeNegate();
     if (ToT == PT_IntAPS)
-      return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE);
+      return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
+             maybeNegate();
 
     if (FromT == ToT)
       return true;
     if (!this->emitCast(*FromT, *ToT, CE))
       return false;
 
-    if (CE->getCastKind() == CK_BooleanToSignedIntegral)
-      return this->emitNeg(*ToT, CE);
-    return true;
+    return maybeNegate();
   }
 
   case CK_PointerToBoolean:
diff --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index 6991a348b07a94..328f38bf21effa 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -91,3 +91,14 @@ namespace Temporaries {
   };
   int &&s = S().w[1];
 }
+
+#ifdef __SIZEOF_INT128__
+namespace bigint {
+  typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
+  constexpr bigint4 A = (bigint4)true;
+  static_assert(A[0] == -1, "");
+  static_assert(A[1] == -1, "");
+  static_assert(A[2] == -1, "");
+  static_assert(A[3] == -1, "");
+}
+#endif

``````````

</details>


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

Reply via email to