[llvm] [PowerPC] extend smaller splats into bigger splats (with fix) (PR #142194)

zhijian lin via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 4 11:07:25 PDT 2025


================
@@ -9785,13 +9802,37 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
                                   dl);
 
   // If the sign extended value is in the range [-16,15], use VSPLTI[bhw].
-  int32_t SextVal = SignExtend32(SplatBits, SplatBitSize);
-  if (SextVal >= -16 && SextVal <= 15)
-    return getCanonicalConstSplat(SextVal, SplatSize, Op.getValueType(), DAG,
-                                  dl);
+  // Use VSPLTIW/VUPKLSW for v2i64 in range [-16,15].
+  if (SextVal >= -16 && SextVal <= 15) {
+    unsigned UseSize = SplatSize == 8 ? 4 : SplatSize;
----------------
diggerlin wrote:

suggest change to 
`unsigned UseSize = SplatSize == 8 ? 4 : 8; `
it is more readable.

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


More information about the llvm-commits mailing list