[llvm] [LoongArch] lower SCALAR_TO_VECTOR to INSERT_VECTOR_ELT (PR #122863)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 18:27:59 PST 2025


================
@@ -255,6 +255,7 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
       setOperationAction(ISD::SETCC, VT, Legal);
       setOperationAction(ISD::VSELECT, VT, Legal);
       setOperationAction(ISD::VECTOR_SHUFFLE, VT, Custom);
+      setOperationAction(ISD::SCALAR_TO_VECTOR, VT, Custom);
----------------
SixWeining wrote:

Yes, I agree. 

For the test case in the commit message, we do too many transforms: insert_vector_elt -> BUILD_VECTOR -> scalar_to_vector -> insert_vector_elt. Could we do: insert_vector_elt -> BUILD_VECTOR -> insert_vector_elt ?

Maybe we should change: [`LoongArchTargetLowering::lowerBUILD_VECTOR()`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp#L1437) or [`SelectionDAGLegalize::ExpandBUILD_VECTOR()`.](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp#L1985)

https://github.com/llvm/llvm-project/pull/122863


More information about the llvm-commits mailing list