Skip to content
Closed
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
38b90ec
todo list
kimyounhoex1 Sep 3, 2025
eb258ba
todo list
kimyounhoex1 Sep 3, 2025
f93dc8f
feat(exprconst): branch statement handling
kimyounhoex1 Sep 3, 2025
eb95364
feat(exprconst): implement shift in compile time
kimyounhoex1 Sep 6, 2025
f00eec1
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 8, 2025
015c774
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
kimyounhoex1 Sep 8, 2025
bed3603
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
kimyounhoex1 Sep 8, 2025
afe7818
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
kimyounhoex1 Sep 8, 2025
6b0dc7b
Title: [clang] VectorExprEvaluator::VisitCallExpr - add constant fold…
kimyounhoex1 Sep 3, 2025
2c6d360
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 11, 2025
9435420
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 11, 2025
e7356b2
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 11, 2025
ee6874b
[clang][test] VectorExprEvaluator::VisitCallExpr - test constant fold…
kimyounhoex1 Sep 11, 2025
814495e
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 11, 2025
7273801
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 12, 2025
2eed8b4
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
RKSimon Sep 16, 2025
2b02883
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
kimyounhoex1 Sep 17, 2025
a587fe8
Merge branch 'user/kimyounhex1/constexpr-slldq-srldq' of https://gith…
kimyounhoex1 Sep 17, 2025
3f4f873
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 18, 2025
7462ae3
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 20, 2025
6164028
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 20, 2025
fd1470e
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 23, 2025
4517c68
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 23, 2025
bc3739a
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 25, 2025
05efd71
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 29, 2025
7811cb8
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
kimyounhoex1 Sep 29, 2025
6a07417
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 29, 2025
bb0f797
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 30, 2025
ce61b54
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 30, 2025
e86f26c
[clang] VectorExprEvaluator::VisitCallExpr - add constant folding for…
kimyounhoex1 Sep 30, 2025
568b6fa
Merge branch 'main' into user/kimyounhex1/constexpr-slldq-srldq
RKSimon Oct 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12001,6 +12001,70 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
}

case X86::BI__builtin_ia32_pslldqi128_byteshift:
case X86::BI__builtin_ia32_psrldqi128_byteshift: {
unsigned BuiltinID = E->getBuiltinCallee();

APSInt Amt;
if (!EvaluateInteger(E->getArg(1), Amt, Info))
break;
unsigned Shift = (unsigned)Amt.getZExtValue();

APValue Vec;
if (!Evaluate(Vec, Info, E->getArg(0)) || !Vec.isVector())
break;

SmallVector<APValue, 16> ResultElements;
ResultElements.reserve(16);

bool isLeft = (BuiltinID == X86::BI__builtin_ia32_pslldqi128_byteshift);

for (unsigned i = 0; i < 16; i++) {
int SrcIdx = -1;
if (isLeft)
SrcIdx = i + Shift;
else if (i >= Shift)
SrcIdx = i - Shift;

if (SrcIdx >= 0 && (unsigned)SrcIdx < 16)
ResultElements.push_back(Vec.getVectorElt(SrcIdx));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't going to work as currently the intrinsics take <X x long long int> types - we're going to have to change these to <8X x char> types to make this a lot easier to deal with - see the palignr builtins for an example

Copy link
Author

@kimyounhoex1 kimyounhoex1 Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m done with this one, could you please check one more?

else
ResultElements.push_back(APValue(0));
}
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
}

case X86::BI__builtin_ia32_pslldqi256_byteshift:
case X86::BI__builtin_ia32_psrldqi256_byteshift: {
unsigned BuiltinID = E->getBuiltinCallee();

APSInt Amt;
if (!EvaluateInteger(E->getArg(1), Amt, Info))
break;
unsigned Shift = (unsigned)Amt.getZExtValue();

APValue Vec;
if (!Evaluate(Vec, Info, E->getArg(0)) || !Vec.isVector())
break;

SmallVector<APValue, 32> ResultElements;
ResultElements.reserve(32);

bool isLeft = (BuiltinID == X86::BI__builtin_ia32_pslldqi256_byteshift);

for (unsigned i = 0; i < 32; i++) {
int SrcIdx = -1;
if (isLeft)
SrcIdx = i + Shift;
else if (i >= Shift)
SrcIdx = i - Shift;

if (SrcIdx >= 0 && (unsigned)SrcIdx < 32)
ResultElements.push_back(Vec.getVectorElt(SrcIdx));
else
ResultElements.push_back(APValue(0));
}

case Builtin::BI__builtin_elementwise_fshl:
case Builtin::BI__builtin_elementwise_fshr: {
APValue SourceHi, SourceLo, SourceShift;
Expand Down
Loading