This is an archive of the discontinued LLVM Phabricator instance.

Implement constexpr BinaryOperator for vector types
ClosedPublic

Authored by erichkeane on May 11 2020, 5:35 PM.

Details

Summary

These operations do member-wise versions of the all of the listed
operations. This patch implements all of the binaryoperators for these
types. Note that the test is required to use codegen as I could not come
up with a good way to validate the values without the array-subscript
operator implemented (which is likely a much more involved change).

This is not full constexpr support for these types, but should at least
support a large number of uses.

Diff Detail

Event Timeline

erichkeane created this revision.May 11 2020, 5:35 PM

Adding some people who know more about this

RKSimon edited reviewers, added: efriedma; removed: eli.friedman.Jun 18 2020, 2:10 AM

Any frontend people got any comments on this? I'm keen to see constexpr vector support added but know next to nothing about the frontend.

aaron.ballman added inline comments.Jun 18 2020, 6:27 AM
clang/lib/AST/ExprConstant.cpp
2699

typo: Should

2741

Typo: Should

2754

const auto *

2778

Might as well remove the spurious whitespace.

2782

How about:

bool Success = true;
if (BinaryOperator::isLogicalOp(Opcode))
  Success = handleLogicalOpForVector(...);
else if (BinaryOperator::isComparisonOp(Opcode))
  Success = handleCompareOpForVector(...);
else
  Success = handleIntIntBinOp(...);

if (!Success) {
  Info.FFDiag(E);
  return false;
}
ResultElements.push_back(...);
2799

emplace_back() instead?

2800

Spurious newline?

2813

emplace_back() instead?

9682

Can you re-flow the rest of the comment now that it's been changed?

erichkeane marked 9 inline comments as done.

@AaronBallman's suggestions.

This revision is now accepted and ready to land.Jun 21 2020, 9:26 AM
RKSimon closed this revision.Jun 22 2020, 12:40 PM

Committed at rGb30c16670e428d09a0854a8f418e46a3e705e4d1 (with a typo in the Differential Revision tag so phab didn't catch it)