[clang] [CIR] Extend VecShuffleOp verifier to catch invalid index (PR #143262)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 06:38:04 PDT 2025
================
@@ -1599,6 +1599,14 @@ LogicalResult cir::VecShuffleOp::verify() {
<< " and " << getResult().getType() << " don't match";
}
+ const uint64_t maxValidIndex =
+ getVec1().getType().getSize() + getVec2().getType().getSize() - 1;
+ for (const auto &idxAttr : getIndices().getAsRange<cir::IntAttr>()) {
----------------
bcardosolopes wrote:
Maybe replace the `for `here by
```
if (llvm::any_of(getIndices().getAsRange<cir::IntAttr>(),
[&](cir::IntAttr idxAttr) {
return idxAttr.getSInt() != -1 && idxAttr.getUInt() > maxValidIndex;
}) emitError(...);
```
https://github.com/llvm/llvm-project/pull/143262
More information about the cfe-commits
mailing list