Skip to content

Commit d6537de

Browse files
committed
Stash
1 parent bcca2d1 commit d6537de

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3580,8 +3580,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
35803580
S, OpPC, Call, [](const APSInt &F, const APSInt &T, const APSInt &C) {
35813581
return ((APInt)C).isNegative() ? T : F;
35823582
});
3583-
case X86::BI__builtin_ia32_ptestz128:
3584-
case X86::BI__builtin_ia32_ptestz256:
3583+
// case X86::BI__builtin_ia32_ptestz128:
3584+
// case X86::BI__builtin_ia32_ptestz256:
35853585

35863586
// case X86::BI__builtin_ia32_ptestc128:
35873587
// case X86::BI__builtin_ia32_ptestc256:

clang/lib/AST/ExprConstant.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12025,8 +12025,58 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1202512025

1202612026
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
1202712027
}
12028-
case X86::BI__builtin_ia32_ptestz128:
12029-
case X86::BI__builtin_ia32_ptestz256:
12028+
case X86::BI__builtin_ia32_ptestz128: {
12029+
APValue SourceLHS, SourceRHS;
12030+
if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) ||
12031+
!EvaluateAsRValue(Info, E->getArg(1), SourceRHS))
12032+
return false;
12033+
12034+
unsigned SourceLen = SourceLHS.getVectorLength();
12035+
bool Flag = true;
12036+
for (unsigned I = 0; I < SourceLen; ++I) {
12037+
const APInt &A = SourceLHS.getVectorElt(I).getInt();
12038+
const APInt &B = SourceRHS.getVectorElt(I).getInt();
12039+
if ((A & B) != 0) {
12040+
Flag = false;
12041+
break;
12042+
}
12043+
}
12044+
12045+
QualType ResultType = E->getType();
12046+
unsigned BitWidth = Info.Ctx.getIntWidth(ResultType);
12047+
bool ResultSigned = ResultType->isUnsignedIntegerOrEnumerationType();
12048+
APSInt Result(APInt(BitWidth, Flag), ResultSigned);
12049+
return Success(APValue(Result), E);
12050+
12051+
// auto *DestTy = E->getType()->castAs<VectorType>();
12052+
// QualType DestEltTy = DestTy->getElementType();
12053+
// bool DestUnsigned = DestEltTy->isUnsignedIntegerOrEnumerationType();
12054+
// const unsigned SourceLen = SourceLHS.getVectorLength();
12055+
// SmallVector<APValue, 4> ResultElements;
12056+
// ResultElements.reserve(SourceLen);
12057+
12058+
// unsigned BitWidth = SourceLHS.getVectorElt(0).getInt().getBitWidth();
12059+
12060+
// auto PopulateResultElements = [&](bool Flag) {
12061+
// for (unsigned I = 0; I < SourceLen - 1; ++I) {
12062+
// ResultElements.emplace_back(APSInt(APInt::getZero(BitWidth), DestUnsigned));
12063+
// }
12064+
// ResultElements.emplace_back(APSInt(APInt(BitWidth, Flag), DestUnsigned));
12065+
// };
12066+
12067+
// for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
12068+
// const APInt &A = SourceLHS.getVectorElt(EltNum).getInt();
12069+
// const APInt &B = SourceRHS.getVectorElt(EltNum).getInt();
12070+
// if ((A & B) != 0) {
12071+
// PopulateResultElements(false);
12072+
// return Success(APValue(ResultElements.data(), SourceLen), E);
12073+
// }
12074+
// }
12075+
// PopulateResultElements(true);
12076+
// return Success(APValue(ResultElements.data(), SourceLen), E);
12077+
}
12078+
12079+
// case clang::X86::BI__builtin_ia32_ptestz256:
1203012080

1203112081
// case X86::BI__builtin_ia32_ptestc128:
1203212082
// case X86::BI__builtin_ia32_ptestc256:

clang/test/CodeGen/X86/sse41-builtins.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
88
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
99

10-
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
11-
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
12-
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
13-
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
14-
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
15-
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
16-
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
17-
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK
10+
1811

1912

2013
#include <immintrin.h>
@@ -471,3 +464,4 @@ int test_mm_testz_si128(__m128i x, __m128i y) {
471464
// CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestz(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})
472465
return _mm_testz_si128(x, y);
473466
}
467+
// TEST_CONSTEXPR(_mm_testz_si128((__m128i)(__v2di){0,0}, (__m128i)(__v2di){0,0}) == 1);

0 commit comments

Comments
 (0)