[llvm] [InitUndef] handleSubReg should skip artificial subregs. (PR #116248)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 07:59:31 PST 2024


================
@@ -164,6 +164,15 @@ bool InitUndef::handleSubReg(MachineFunction &MF, MachineInstr &MI,
     TRI->getCoveringSubRegIndexes(*MRI, TargetRegClass, NeedDef,
                                   SubRegIndexNeedInsert);
 
+    // It's not possible to create the INIT_UNDEF when there is no register
+    // class associated for the subreg. This may happen for artificial subregs
+    // that are not directly addressable.
+    if (any_of(SubRegIndexNeedInsert,
+               [&TRI = TRI, &TargetRegClass](unsigned ind) -> bool {
+                 return !TRI->getSubRegisterClass(TargetRegClass, ind);
----------------
nikic wrote:

```suggestion
    if (any_of(SubRegIndexNeedInsert,
               [&](unsigned Ind) -> bool {
                 return !TRI->getSubRegisterClass(TargetRegClass, Ind);
```

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


More information about the llvm-commits mailing list