Skip to content

Commit 3d905d8

Browse files
committed
Apply feedback
1 parent 0a21761 commit 3d905d8

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,10 +2826,9 @@ static bool interp__builtin_ia32_test_op(
28262826
assert(LHS.getNumElems() == RHS.getNumElems());
28272827

28282828
unsigned SourceLen = LHS.getNumElems();
2829-
const QualType ElemQT = getElemType(LHS);
2830-
const OptPrimType ElemPT = S.getContext().classify(ElemQT);
2829+
QualType ElemQT = getElemType(LHS);
2830+
OptPrimType ElemPT = S.getContext().classify(ElemQT);
28312831
unsigned LaneWidth = S.getASTContext().getTypeSize(ElemQT);
2832-
APInt SignMask = APInt::getSignMask(LaneWidth);
28332832

28342833
APInt AWide(LaneWidth * SourceLen, 0);
28352834
APInt BWide(LaneWidth * SourceLen, 0);
@@ -2838,16 +2837,16 @@ static bool interp__builtin_ia32_test_op(
28382837
APInt ALane;
28392838
APInt BLane;
28402839

2841-
if (ElemQT->isIntegerType()) { // Get value
2840+
if (ElemQT->isIntegerType()) { // Get value.
28422841
INT_TYPE_SWITCH_NO_BOOL(*ElemPT, {
28432842
ALane = LHS.elem<T>(I).toAPSInt();
28442843
BLane = RHS.elem<T>(I).toAPSInt();
28452844
});
2846-
} else if (ElemQT->isFloatingType()) { // Get only sign bit
2845+
} else if (ElemQT->isFloatingType()) { // Get only sign bit.
28472846
using T = PrimConv<PT_Float>::T;
2848-
ALane = LHS.elem<T>(I).getAPFloat().bitcastToAPInt() & SignMask;
2849-
BLane = RHS.elem<T>(I).getAPFloat().bitcastToAPInt() & SignMask;
2850-
} else { // Must be integer or floating type
2847+
ALane = LHS.elem<T>(I).getAPFloat().bitcastToAPInt().isNegative();
2848+
BLane = RHS.elem<T>(I).getAPFloat().bitcastToAPInt().isNegative();
2849+
} else { // Must be integer or floating type.
28512850
return false;
28522851
}
28532852
AWide.insertBits(ALane, I * LaneWidth);

clang/lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13775,26 +13775,28 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1377513775

1377613776
unsigned SourceLen = SourceLHS.getVectorLength();
1377713777
const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
13778-
const QualType ElemQT = VT->getElementType();
13778+
QualType ElemQT = VT->getElementType();
1377913779
unsigned LaneWidth = Info.Ctx.getTypeSize(ElemQT);
13780-
APInt SignMask = APInt::getSignMask(LaneWidth);
1378113780

1378213781
APInt AWide(LaneWidth * SourceLen, 0);
1378313782
APInt BWide(LaneWidth * SourceLen, 0);
1378413783

1378513784
for (unsigned I = 0; I != SourceLen; ++I) {
1378613785
APInt ALane;
1378713786
APInt BLane;
13788-
13789-
if (ElemQT->isIntegerType()) { // Get value
13787+
if (ElemQT->isIntegerType()) { // Get value.
1379013788
ALane = SourceLHS.getVectorElt(I).getInt();
1379113789
BLane = SourceRHS.getVectorElt(I).getInt();
13792-
} else if (ElemQT->isFloatingType()) { // Get only sign bit
13793-
ALane = SourceLHS.getVectorElt(I).getFloat().bitcastToAPInt() &
13794-
SignMask;
13795-
BLane = SourceRHS.getVectorElt(I).getFloat().bitcastToAPInt() &
13796-
SignMask;
13797-
} else { // Must be integer or floating type
13790+
} else if (ElemQT->isFloatingType()) { // Get only sign bit.
13791+
ALane = SourceLHS.getVectorElt(I)
13792+
.getFloat()
13793+
.bitcastToAPInt()
13794+
.isNegative();
13795+
BLane = SourceRHS.getVectorElt(I)
13796+
.getFloat()
13797+
.bitcastToAPInt()
13798+
.isNegative();
13799+
} else { // Must be integer or floating type.
1379813800
return false;
1379913801
}
1380013802
AWide.insertBits(ALane, I * LaneWidth);

0 commit comments

Comments
 (0)