-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][Interp] Fix BooleanToSignedIntegral casts for IntAP(S) #102302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesWe were not doing the final Neg here. Full diff: https://github.com/llvm/llvm-project/pull/102302.diff 2 Files Affected:
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
|
We were not doing the final Neg here.
0b1a9b4
to
6de1136
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/1875 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/72/builds/1984 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/2570 Here is the relevant piece of the build log for the reference:
|
We were not doing the final Neg here.