[llvm] [LSV] Insert casts to vectorize mismatched types (PR #134436)
Anshil Gandhi via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 13 13:15:41 PDT 2025
================
@@ -1310,6 +1315,116 @@ std::optional<APInt> Vectorizer::getConstantOffsetSelects(
return std::nullopt;
}
+void Vectorizer::insertCastsToMergeClasses(EquivalenceClassMap &EQClasses) {
+ if (EQClasses.size() < 2)
+ return;
+
+ // For each class, determine if all instructions are of type int, FP or ptr.
+ // This information will help us determine the type instructions should be
+ // casted into.
+ MapVector<EqClassKey, Bitset<3>> ClassAllTy;
+ for (auto C : EQClasses) {
+ if (all_of(EQClasses[C.first], [](Instruction *I) {
+ return I->getType()->isIntOrIntVectorTy();
+ }))
+ ClassAllTy[C.first].set(0);
+ else if (all_of(EQClasses[C.first], [](Instruction *I) {
+ return I->getType()->isFPOrFPVectorTy();
+ }))
+ ClassAllTy[C.first].set(1);
+ else if (all_of(EQClasses[C.first], [](Instruction *I) {
+ return I->getType()->isPtrOrPtrVectorTy();
----------------
gandhi56 wrote:
Classes are only merged if their instructions belong to the same addrspace. All instructions within a class belong to the same addrspace, by definition. Unless I misunderstood, I don't think addrspace mismatch needs to be checked here.
https://github.com/llvm/llvm-project/pull/134436
More information about the llvm-commits
mailing list