Skip to content

Commit f9b8e74

Browse files
committed
Apply feedback for ExprConstant.cpp
1 parent 1507644 commit f9b8e74

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14805,29 +14805,29 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1480514805
return false;
1480614806
unsigned SourceLen = Source.getVectorLength();
1480714807
const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
14808-
const QualType ElemQT = VT->getElementType();
14809-
unsigned LaneWidth = Info.Ctx.getTypeSize(ElemQT);
14810-
14811-
if (ElemQT->isIntegerType()) { // Get MSB of each byte of every lane
14812-
unsigned Byte = 8;
14813-
unsigned ResultLen = (LaneWidth * SourceLen) / Byte;
14814-
APInt Result(ResultLen, 0);
14808+
QualType ElemQT = VT->getElementType();
14809+
unsigned ResultLen = Info.Ctx.getTypeSize(
14810+
E->getCallReturnType(Info.Ctx)); // Always 32-bit integer.
14811+
APInt Result(ResultLen, 0);
14812+
14813+
if (ElemQT->isIntegerType()) { // Get MSB of each byte of every lane.
14814+
unsigned BitsInAByte = 8;
14815+
unsigned LaneWidth = Info.Ctx.getTypeSize(ElemQT);
1481514816
unsigned ResultIdx = 0;
1481614817
for (unsigned I = 0; I != SourceLen; ++I) {
1481714818
APInt Lane = Source.getVectorElt(I).getInt();
14818-
for (unsigned J = 0; J != LaneWidth; J += Byte) {
14819+
for (unsigned J = 0; J != LaneWidth; J += BitsInAByte) {
1481914820
Result.setBitVal(ResultIdx++, Lane[J + 7]);
1482014821
}
1482114822
}
14822-
return Success(Result.getZExtValue(), E);
14823+
return Success(Result, E);
1482314824
}
14824-
if (ElemQT->isFloatingType()) { // Get sign bit of every lane
14825-
APInt Result(SourceLen, 0);
14825+
if (ElemQT->isRealFloatingType()) { // Get sign bit of every lane.
1482614826
for (unsigned I = 0; I != SourceLen; ++I) {
1482714827
APInt Lane = Source.getVectorElt(I).getFloat().bitcastToAPInt();
14828-
Result.setBitVal(I, Lane[LaneWidth - 1]);
14828+
Result.setBitVal(I, Lane.isNegative());
1482914829
}
14830-
return Success(Result.getZExtValue(), E);
14830+
return Success(Result, E);
1483114831
}
1483214832
return false;
1483314833
}

0 commit comments

Comments
 (0)