This revision was automatically updated to reflect the committed changes. Closed by commit rG14947cd04701: [clang] Fix signedness in vector bitcast evaluation (authored by svenvh).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D95135/new/ 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 @@ -10193,7 +10193,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);
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 @@ -10193,7 +10193,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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits