From: Craig Topper Date: Sat, 8 Apr 2023 06:38:04 +0000 (-0700) Subject: [TableGen] Simplify TypeInfer::expandOverloads. NFC X-Git-Tag: upstream/17.0.6~12262 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09fecbbf5409e321f5e45b8120c26b12b8b742e6;p=platform%2Fupstream%2Fllvm.git [TableGen] Simplify TypeInfer::expandOverloads. NFC Directly test the 5 overloaded types instead of doing extra set creation and iteration. --- diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index a110497..a781746 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -819,56 +819,41 @@ void TypeInfer::expandOverloads(TypeSetByHwMode &VTS) { void TypeInfer::expandOverloads(TypeSetByHwMode::SetType &Out, const TypeSetByHwMode::SetType &Legal) { - std::set Ovs; - for (MVT T : Out) { - if (!T.isOverloaded()) - continue; - - Ovs.insert(T); - // MachineValueTypeSet allows iteration and erasing. - Out.erase(T); - } - - for (MVT Ov : Ovs) { - switch (Ov.SimpleTy) { - case MVT::iPTRAny: - Out.insert(MVT::iPTR); - return; - case MVT::iAny: - for (MVT T : MVT::integer_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - for (MVT T : MVT::integer_fixedlen_vector_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - for (MVT T : MVT::integer_scalable_vector_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - return; - case MVT::fAny: - for (MVT T : MVT::fp_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - for (MVT T : MVT::fp_fixedlen_vector_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - for (MVT T : MVT::fp_scalable_vector_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - return; - case MVT::vAny: - for (MVT T : MVT::vector_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - return; - case MVT::Any: - for (MVT T : MVT::all_valuetypes()) - if (Legal.count(T)) - Out.insert(T); - return; - default: - break; - } + if (Out.count(MVT::iPTRAny)) { + Out.erase(MVT::iPTRAny); + Out.insert(MVT::iPTR); + } else if (Out.count(MVT::iAny)) { + Out.erase(MVT::iAny); + for (MVT T : MVT::integer_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + for (MVT T : MVT::integer_fixedlen_vector_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + for (MVT T : MVT::integer_scalable_vector_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + } else if (Out.count(MVT::fAny)) { + Out.erase(MVT::fAny); + for (MVT T : MVT::fp_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + for (MVT T : MVT::fp_fixedlen_vector_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + for (MVT T : MVT::fp_scalable_vector_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + } else if (Out.count(MVT::vAny)) { + Out.erase(MVT::vAny); + for (MVT T : MVT::vector_valuetypes()) + if (Legal.count(T)) + Out.insert(T); + } else if (Out.count(MVT::Any)) { + Out.erase(MVT::Any); + for (MVT T : MVT::all_valuetypes()) + if (Legal.count(T)) + Out.insert(T); } }