[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 10:23:36 PDT 2025


================
@@ -9664,7 +9664,25 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
     }
   }
 
-  if (!BVNIsConstantSplat || SplatBitSize > 32) {
+  bool IsSplat64 = false;
+  uint64_t SplatBits = 0;
+  int32_t SextVal = 0;
+  if (BVNIsConstantSplat) {
+    if (SplatBitSize <= 32) {
+      SplatBits = APSplatBits.getZExtValue();
+      SextVal = SignExtend32(SplatBits, SplatBitSize);
+    } else if (SplatBitSize == 64 && Subtarget.hasP8Altivec()) {
+      int64_t Splat64Val = APSplatBits.getSExtValue();
+      SplatBits = (uint64_t)Splat64Val;
+      SextVal = (int32_t)SplatBits;
----------------
diggerlin wrote:

this is C style cast, suggest change to 

```
SplatBits = static_cast<uint64_t>(Splat64Val);
SextVal = static_cast<int32_t>(SplatBits); 
```

since the SplatBits  is not used , we can change to
`SextVal = static_cast<int32_t>(Splat64Val); `

and we can hoist  `APSplatBits.getZExtValue();` to after `if (BVNIsConstantSplat) {`

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


More information about the llvm-commits mailing list