================
@@ -4551,6 +4552,20 @@ static Constant *ConstantFoldFixedVectorCall(
}
return nullptr;
}
+ case Intrinsic::mask_beforefirst: {
+ bool SeenActive = false;
+ for (unsigned I = 0, E = FVTy->getNumElements(); I != E; ++I) {
+ Constant *Elt = Operands[0]->getAggregateElement(I);
+ if (isa_and_nonnull<PoisonValue>(Elt))
+ return PoisonValue::get(FVTy);
+ if (auto *CI = dyn_cast_or_null<ConstantInt>(Elt))
+ SeenActive |= CI->isOne();
+ else if (!isa_and_nonnull<UndefValue>(Elt))
+ return nullptr;
----------------
nikic wrote:
Undef seems unlikely to be relevant in this context, I'd rather just not handle
it.
We could also ignore unknown elements of SeenActive is already true. But again,
that seems unlikely to be relevant (would need a constant expression inside the
vector).
https://github.com/llvm/llvm-project/pull/234472
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits