This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Add ExtVectorElementExpr constant evaluation (PR42387)
ClosedPublic

Authored by svenvh on Dec 6 2019, 10:36 AM.

Details

Summary

Add constexpr evaluation for ExtVectorElementExpr nodes by evaluating
the underlying vector expression.

Add basic folding too, for the case that Evaluate does not return an
LValue.

Diff Detail

Event Timeline

svenvh created this revision.Dec 6 2019, 10:36 AM
Anastasia added inline comments.Dec 10 2019, 8:48 AM
clang/lib/AST/ExprConstant.cpp
7088

can Val not be vector at this point?

svenvh marked an inline comment as done.Dec 11 2019, 2:13 AM
svenvh added inline comments.
clang/lib/AST/ExprConstant.cpp
7088

Yes, for example when evaluating const int2 fromConstexprFunc = addOne(int2(2)); from the included test case we get an LValue (that won't be folded by the code below).

Anastasia accepted this revision.Dec 12 2019, 4:12 AM

LGTM! Thanks!

clang/lib/AST/ExprConstant.cpp
7088

I see. Would it be folded elsewhere or not folded at all?

This revision is now accepted and ready to land.Dec 12 2019, 4:12 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2019, 3:19 AM