[PATCH] D95135: Fix signedness in vector bitcast evaluation
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 21 07:14:21 PST 2021
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The included test case triggered a sign assertion on the result in
`Success()`. This was caused by the APSInt created for a bitcast
having its signedness bit inverted. The second APSInt constructor
argument is `isUnsigned`, so invert the result of
`isSignedIntegerType`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95135
Files:
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenOpenCL/vector_literals.cl
Index: clang/test/CodeGenOpenCL/vector_literals.cl
===================================================================
--- clang/test/CodeGenOpenCL/vector_literals.cl
+++ clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,3 +63,10 @@
//CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float>* %V2
float4 V2 = (float4)(1);
}
+
+void vector_literals_with_cast() {
+ // CHECK-LABEL: vector_literals_with_cast
+ // CHECK: store <2 x i32> <i32 12, i32 34>, <2 x i32>*
+ // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
+ unsigned int withCast = ((int2)((int2)(12, 34))).s0;
+}
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10206,7 +10206,7 @@
Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
else
Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
- Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType())));
+ Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType())));
}
} else {
return Error(E);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95135.318191.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210121/5ab6fc55/attachment.bin>
More information about the cfe-commits
mailing list