Skip to content

Commit a64af80

Browse files
committed
Apply feedback
1 parent 29202f4 commit a64af80

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,11 +3816,12 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
38163816
case X86::BI__builtin_ia32_psignd128:
38173817
case X86::BI__builtin_ia32_psignd256:
38183818
return interp__builtin_elementwise_int_binop(
3819-
S, OpPC, Call, [](const APSInt &AElem, const APSInt &BElem) -> APInt {
3820-
return BElem[BElem.getBitWidth() - 1]
3821-
? static_cast<const APInt &>(-AElem)
3822-
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
3823-
: static_cast<const APInt &>(AElem);
3819+
S, OpPC, Call, [](const APInt &AElem, const APInt &BElem) {
3820+
if (BElem.isZero())
3821+
return APInt::getZero(AElem.getBitWidth());
3822+
if (BElem.isNegative())
3823+
return -AElem;
3824+
return AElem;
38243825
});
38253826

38263827
case clang::X86::BI__builtin_ia32_pavgb128:

clang/lib/AST/ExprConstant.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12318,11 +12318,13 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1231812318
case X86::BI__builtin_ia32_psignw256:
1231912319
case X86::BI__builtin_ia32_psignd128:
1232012320
case X86::BI__builtin_ia32_psignd256:
12321-
return EvaluateBinOpExpr([](const APSInt &AElem,
12322-
const APSInt &BElem) -> APInt {
12323-
return BElem[BElem.getBitWidth() - 1] ? static_cast<const APInt &>(-AElem)
12324-
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
12325-
: static_cast<const APInt &>(AElem);
12321+
return EvaluateBinOpExpr([](const APInt &AElem,
12322+
const APInt &BElem) -> APInt {
12323+
if (BElem.isZero())
12324+
return APInt::getZero(AElem.getBitWidth());
12325+
if (BElem.isNegative())
12326+
return -AElem;
12327+
return AElem;
1232612328
});
1232712329

1232812330
case X86::BI__builtin_ia32_blendvpd:

0 commit comments

Comments
 (0)