[llvm] [RISCV] Fix more boundary cases in immediate selection for Zdinx load/store on RV32. (PR #105874)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 25 00:47:43 PDT 2024


================
@@ -2649,20 +2654,44 @@ bool RISCVDAGToDAGISel::SelectAddrRegRegScale(SDValue Addr,
 }
 
 bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
-                                         SDValue &Offset, bool IsINX) {
+                                         SDValue &Offset, bool IsRV32Zdinx) {
   if (SelectAddrFrameIndex(Addr, Base, Offset))
     return true;
 
   SDLoc DL(Addr);
   MVT VT = Addr.getSimpleValueType();
 
   if (Addr.getOpcode() == RISCVISD::ADD_LO) {
-    Base = Addr.getOperand(0);
-    Offset = Addr.getOperand(1);
-    return true;
+    // If this is non RV32Zdinx we can always fold.
+    if (!IsRV32Zdinx) {
+      Base = Addr.getOperand(0);
+      Offset = Addr.getOperand(1);
+      return true;
+    }
+
+    // For RV32Zdinx we need to have more than 4 byte alignment so we can add 4
+    // to the offset when we expandin RISCVExpandPseudoInsts.
----------------
dtcxzyw wrote:

```suggestion
    // to the offset when we expand in RISCVExpandPseudoInsts.
```

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


More information about the llvm-commits mailing list