Skip to content

Commit 20fcfaa

Browse files
committed
Commit changes for clang-format
1 parent 6587f3e commit 20fcfaa

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,39 @@ static bool interp__builtin_blend(InterpState &S, CodePtr OpPC,
28512851
return true;
28522852
}
28532853

2854+
static bool interp__builtin_ptestz(InterpState &S, CodePtr OpPC,
2855+
const CallExpr *Call) {
2856+
const Pointer &LHS = S.Stk.pop<Pointer>();
2857+
const Pointer &RHS = S.Stk.pop<Pointer>();
2858+
2859+
assert(LHS.getNumElems() == RHS.getNumElems());
2860+
assert(LHS.getFieldDesc()->isPrimitiveArray() &&
2861+
RHS.getFieldDesc()->isPrimitiveArray());
2862+
2863+
if (!S.getASTContext().hasSameUnqualifiedType(getElemType(LHS),
2864+
getElemType(RHS)))
2865+
return false;
2866+
2867+
unsigned SourceLen = LHS.getNumElems();
2868+
const QualType ElemQT = getElemType(LHS);
2869+
const OptPrimType ElemPT = S.getContext().classify(ElemQT);
2870+
2871+
bool Flag = true;
2872+
INT_TYPE_SWITCH_NO_BOOL(*ElemPT, {
2873+
for (unsigned I = 0; I < SourceLen; ++I) {
2874+
const APSInt A = LHS.elem<T>(I).toAPSInt();
2875+
const APSInt B = RHS.elem<T>(I).toAPSInt();
2876+
if ( (A & B) != 0 ) {
2877+
Flag = false;
2878+
break;
2879+
}
2880+
}
2881+
});
2882+
2883+
pushInteger(S, Flag ? 1 : 0, Call->getType());
2884+
return true;
2885+
}
2886+
28542887
static bool interp__builtin_elementwise_triop(
28552888
InterpState &S, CodePtr OpPC, const CallExpr *Call,
28562889
llvm::function_ref<APInt(const APSInt &, const APSInt &, const APSInt &)>
@@ -3581,9 +3614,9 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
35813614
return ((APInt)C).isNegative() ? T : F;
35823615
});
35833616

3584-
case X86::BI__builtin_ia32_ptestz128: {
3585-
}
3586-
3617+
case X86::BI__builtin_ia32_ptestz128:
3618+
return interp__builtin_ptestz(S, OpPC, Call);
3619+
35873620
// case X86::BI__builtin_ia32_ptestz256:
35883621

35893622
// case X86::BI__builtin_ia32_ptestc128:

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
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-
11-
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
1218

1319
#include <immintrin.h>
1420
#include "builtin_test_helpers.h"

0 commit comments

Comments
 (0)