Skip to content

Commit 83aa1fd

Browse files
committed
Fix style and format
1 parent 7dce6c6 commit 83aa1fd

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,14 +4474,13 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
44744474
return interp__builtin_ia32_shuffle_generic(
44754475
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
44764476
uint8_t Ctlb = static_cast<uint8_t>(ShuffleMask);
4477-
if (Ctlb & 0x80) {
4477+
if (Ctlb & 0x80)
44784478
return std::make_pair(0, -1);
4479-
} else {
4480-
unsigned LaneBase = (DstIdx / 16) * 16;
4481-
unsigned SrcOffset = Ctlb & 0x0F;
4482-
unsigned SrcIdx = LaneBase + SrcOffset;
4483-
return std::make_pair(0, static_cast<int>(SrcIdx));
4484-
}
4479+
4480+
unsigned LaneBase = (DstIdx / 16) * 16;
4481+
unsigned SrcOffset = Ctlb & 0x0F;
4482+
unsigned SrcIdx = LaneBase + SrcOffset;
4483+
return std::make_pair(0, static_cast<int>(SrcIdx));
44854484
});
44864485

44874486
case X86::BI__builtin_ia32_pshuflw:
@@ -4494,9 +4493,9 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
44944493
if (LaneIdx < 4) {
44954494
unsigned Sel = (ShuffleMask >> (2 * LaneIdx)) & 0x3;
44964495
return std::make_pair(0, static_cast<int>(LaneBase + Sel));
4497-
} else {
4498-
return std::make_pair(0, static_cast<int>(DstIdx));
44994496
}
4497+
4498+
return std::make_pair(0, static_cast<int>(DstIdx));
45004499
});
45014500

45024501
case X86::BI__builtin_ia32_pshufhw:
@@ -4509,9 +4508,9 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
45094508
if (LaneIdx >= 4) {
45104509
unsigned Sel = (ShuffleMask >> (2 * (LaneIdx - 4))) & 0x3;
45114510
return std::make_pair(0, static_cast<int>(LaneBase + 4 + Sel));
4512-
} else {
4513-
return std::make_pair(0, static_cast<int>(DstIdx));
45144511
}
4512+
4513+
return std::make_pair(0, static_cast<int>(DstIdx));
45154514
});
45164515

45174516
case X86::BI__builtin_ia32_pshufd:
@@ -4686,12 +4685,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
46864685
[](unsigned DstIdx, unsigned Shift) -> std::pair<unsigned, int> {
46874686
unsigned LaneBase = (DstIdx / 16) * 16;
46884687
unsigned LaneIdx = DstIdx % 16;
4689-
if (LaneIdx < Shift) {
4688+
if (LaneIdx < Shift)
46904689
return std::make_pair(0, -1);
4691-
}
4692-
4693-
return std::make_pair(0, static_cast<int>(LaneBase + LaneIdx - Shift));
46944690

4691+
return std::make_pair(0,
4692+
static_cast<int>(LaneBase + LaneIdx - Shift));
46954693
});
46964694

46974695
case X86::BI__builtin_ia32_psrldqi128_byteshift:
@@ -4706,9 +4704,9 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
47064704
[](unsigned DstIdx, unsigned Shift) -> std::pair<unsigned, int> {
47074705
unsigned LaneBase = (DstIdx / 16) * 16;
47084706
unsigned LaneIdx = DstIdx % 16;
4709-
if (LaneIdx + Shift < 16) {
4710-
return std::make_pair(0, static_cast<int>(LaneBase + LaneIdx + Shift));
4711-
}
4707+
if (LaneIdx + Shift < 16)
4708+
return std::make_pair(0,
4709+
static_cast<int>(LaneBase + LaneIdx + Shift));
47124710

47134711
return std::make_pair(0, -1);
47144712
});

clang/lib/AST/ExprConstant.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12146,11 +12146,15 @@ static bool evalShuffleGeneric(
1214612146
if (SrcIdx < 0) {
1214712147
// Zero out this element
1214812148
QualType ElemTy = VT->getElementType();
12149-
if (ElemTy->isFloatingType()) {
12149+
if (ElemTy->isRealFloatingType()) {
1215012150
ResultElements.push_back(
1215112151
APValue(APFloat::getZero(Info.Ctx.getFloatTypeSemantics(ElemTy))));
12152+
} else if (ElemTy->isIntegerType()) {
12153+
APValue Zero(Info.Ctx.MakeIntValue(0, ElemTy));
12154+
ResultElements.push_back(APValue(Zero));
1215212155
} else {
12153-
ResultElements.push_back(APValue(Info.Ctx.MakeIntValue(0, ElemTy)));
12156+
// Other types of fallback logic
12157+
ResultElements.push_back(APValue());
1215412158
}
1215512159
} else {
1215612160
const APValue &Src = (SrcVecIdx == 0) ? A : B;
@@ -12929,16 +12933,16 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1292912933
APValue R;
1293012934
if (!evalShuffleGeneric(
1293112935
Info, E, R,
12932-
[](unsigned DstIdx, unsigned ShuffleMask) -> std::pair<unsigned, int> {
12936+
[](unsigned DstIdx,
12937+
unsigned ShuffleMask) -> std::pair<unsigned, int> {
1293312938
uint8_t Ctlb = static_cast<uint8_t>(ShuffleMask);
12934-
if (Ctlb & 0x80) {
12939+
if (Ctlb & 0x80)
1293512940
return std::make_pair(0, -1);
12936-
} else {
12937-
unsigned LaneBase = (DstIdx / 16) * 16;
12938-
unsigned SrcOffset = Ctlb & 0x0F;
12939-
unsigned SrcIdx = LaneBase + SrcOffset;
12940-
return std::make_pair(0, static_cast<int>(SrcIdx));
12941-
}
12941+
12942+
unsigned LaneBase = (DstIdx / 16) * 16;
12943+
unsigned SrcOffset = Ctlb & 0x0F;
12944+
unsigned SrcIdx = LaneBase + SrcOffset;
12945+
return std::make_pair(0, static_cast<int>(SrcIdx));
1294212946
}))
1294312947
return false;
1294412948
return Success(R, E);
@@ -12961,7 +12965,7 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1296112965
unsigned Sel = (Mask >> (2 * LaneIdx)) & 0x3;
1296212966
return std::make_pair(0, static_cast<int>(LaneBase + Sel));
1296312967
}
12964-
return std::make_pair(0, static_cast<int>(DstIdx));
12968+
return std::make_pair(0, static_cast<int>(DstIdx));
1296512969
}))
1296612970
return false;
1296712971
return Success(R, E);
@@ -12983,9 +12987,10 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1298312987
if (LaneIdx >= HalfSize) {
1298412988
unsigned Rel = LaneIdx - HalfSize;
1298512989
unsigned Sel = (Mask >> (2 * Rel)) & 0x3;
12986-
return std::make_pair(0, static_cast<int>(LaneBase + HalfSize + Sel));
12990+
return std::make_pair(
12991+
0, static_cast<int>(LaneBase + HalfSize + Sel));
1298712992
}
12988-
return std::make_pair(0, static_cast<int>(DstIdx));
12993+
return std::make_pair(0, static_cast<int>(DstIdx));
1298912994
}))
1299012995
return false;
1299112996
return Success(R, E);
@@ -13491,14 +13496,15 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1349113496
[](unsigned DstIdx, unsigned Shift) -> std::pair<unsigned, int> {
1349213497
unsigned LaneBase = (DstIdx / 16) * 16;
1349313498
unsigned LaneIdx = DstIdx % 16;
13494-
if (LaneIdx < Shift) {
13499+
if (LaneIdx < Shift)
1349513500
return std::make_pair(0, -1);
13496-
}
13497-
return std::make_pair(0, static_cast<int>(LaneBase + LaneIdx - Shift));
13501+
13502+
return std::make_pair(
13503+
0, static_cast<int>(LaneBase + LaneIdx - Shift));
1349813504
}))
1349913505
return false;
1350013506
return Success(R, E);
13501-
}
13507+
}
1350213508

1350313509
case X86::BI__builtin_ia32_psrldqi128_byteshift:
1350413510
case X86::BI__builtin_ia32_psrldqi256_byteshift:
@@ -13509,14 +13515,15 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1350913515
[](unsigned DstIdx, unsigned Shift) -> std::pair<unsigned, int> {
1351013516
unsigned LaneBase = (DstIdx / 16) * 16;
1351113517
unsigned LaneIdx = DstIdx % 16;
13512-
if (LaneIdx + Shift < 16) {
13513-
return std::make_pair(0, static_cast<int>(LaneBase + LaneIdx + Shift));
13514-
}
13515-
return std::make_pair(0, -1);
13518+
if (LaneIdx + Shift < 16)
13519+
return std::make_pair(
13520+
0, static_cast<int>(LaneBase + LaneIdx + Shift));
13521+
13522+
return std::make_pair(0, -1);
1351613523
}))
1351713524
return false;
1351813525
return Success(R, E);
13519-
}
13526+
}
1352013527
case X86::BI__builtin_ia32_vpermi2varq128:
1352113528
case X86::BI__builtin_ia32_vpermi2varpd128: {
1352213529
APValue R;

0 commit comments

Comments
 (0)