-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang][bytecode] Fix D3DCOLORtoUBYTE4 hlsl test #151819
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
HLSL is using CK_FloatingToIntegral casts to cast to vectors, which we don't support (neither does the current interpreter). Also fix a crash when trying to promote the HLSL bool, which can't be promoted it seems.
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesHLSL is using CK_FloatingToIntegral casts to cast to vectors, which we don't support (neither does the current interpreter). Also fix a crash when trying to promote the HLSL bool, which can't be promoted it seems. Full diff: https://github.com/llvm/llvm-project/pull/151819.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8b9e5e0cb318e..6e451acd4b6b4 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -331,6 +331,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
}
case CK_FloatingToIntegral: {
+ if (!CE->getType()->isIntegralOrEnumerationType())
+ return false;
if (!this->visit(SubExpr))
return false;
PrimType ToT = classifyPrim(CE);
@@ -1369,10 +1371,15 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
// BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
// integer promotion.
bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || E->isShiftOp());
- QualType PromotTy =
- Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
- PrimType PromotT = classifyPrim(PromotTy);
- PrimType OpT = NeedIntPromot ? PromotT : ElemT;
+ QualType PromotTy;
+ PrimType PromotT = PT_Bool;
+ PrimType OpT = ElemT;
+ if (NeedIntPromot) {
+ PromotTy =
+ Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
+ PromotT = classifyPrim(PromotTy);
+ OpT = PromotT;
+ }
auto getElem = [=](unsigned Offset, PrimType ElemT, unsigned Index) {
if (!this->emitGetLocal(PT_Ptr, Offset, E))
diff --git a/clang/test/AST/ByteCode/hlsl.hlsl b/clang/test/AST/ByteCode/hlsl.hlsl
index 073e430191991..60a7f44c443a2 100644
--- a/clang/test/AST/ByteCode/hlsl.hlsl
+++ b/clang/test/AST/ByteCode/hlsl.hlsl
@@ -29,3 +29,11 @@ export void fn() {
// smaller vector, then truncated to a float as a constant expression.
_Static_assert(((float2)float4(6, 5, 4, 3)).x == 6, "Woo!");
}
+
+int4 test_D3DCOLORtoUBYTE4(float4 p1) {
+ return D3DCOLORtoUBYTE4(p1);
+}
+
+int4 test_constant_inputs() {
+ return D3DCOLORtoUBYTE4(float4(0, 11.11, -50.5, 100));
+}
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/21103 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/186/builds/11257 Here is the relevant piece of the build log for the reference |
HLSL is using CK_FloatingToIntegral casts to cast to vectors, which we don't support (neither does the current interpreter). Also fix a crash when trying to promote the HLSL bool, which can't be promoted it seems.