[llvm] [NVPTX] fold movs into loads and stores (PR #144581)

Princeton Ferro via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 14:53:11 PDT 2025


================
@@ -3464,19 +3464,16 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
       unsigned I = 0;
       for (const unsigned NumElts : VectorInfo) {
         const EVT EltVT = VTs[I];
-        const EVT LoadVT = [&]() -> EVT {
-          // i1 is loaded/stored as i8.
-          if (EltVT == MVT::i1)
-            return MVT::i8;
-          // getLoad needs a vector type, but it can't handle
-          // vectors which contain v2f16 or v2bf16 elements. So we must load
-          // using i32 here and then bitcast back.
-          if (EltVT.isVector())
-            return MVT::getIntegerVT(EltVT.getFixedSizeInBits());
-          return EltVT;
-        }();
+        // i1 is loaded/stored as i8
----------------
Prince781 wrote:

Before this change, a parameter with type `<4 x half>` would be turned into:

```
L: v2i32,ch = load <param_0>
v: v4f16 = bitcast L:0
...
```

Which would be lowered as:

```
L: i32,i32,ch = LoadV2 <param_0>
```

This type erasure would complicate the pattern matching rules and also hinders some other optimizations (for example, some test cases now generate `abs.bf16x2` instead of `and.b32`).

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


More information about the llvm-commits mailing list