[PATCH] D128899: [LoongArch] Add codegen support for fpround, fpextend and converting between signed integer and floating-point

Gong LingQin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 23:40:44 PDT 2022


gonglingqin added inline comments.


================
Comment at: llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td:17-20
+def SDT_LoongArchMOVGR2FR_W_LA64
+    : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisVT<1, i64>]>;
+def SDT_LoongArchMOVFR2GR_S_LA64
+    : SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, f32>]>;
----------------
xen0n wrote:
> Actually I don't quite get why this needs to be different just for LA64. Isn't the behavior for these two insns identical between LA32 and LA64?
Yes, but we only use these two SDNodes for LA64. In LA32, we use bitconvert, such as (LoongArchFloat32InstrInfo. td, line 224-227)
// GPR -> FPR
def : Pat<(bitconvert (i32 GPR:$src)), (MOVGR2FR_W GPR:$src)>;
// FPR -> GPR
def : Pat<(i32 (bitconvert FPR32:$src)), (MOVFR2GR_S FPR32:$src)>;
Thanks.


================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:131-133
+    SDValue FPConv =
+        DAG.getNode(LoongArchISD::MOVGR2FR_W_LA64, DL, MVT::f32, NewOp0);
+    return FPConv;
----------------
xen0n wrote:
> 
Thanks for the suggestion, I will change that.


================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.h:38
 
+  // FP to int conversions
+  MOVGR2FR_W_LA64,
----------------
xen0n wrote:
> `movgr2fr` is definitely not "FP to int". Maybe this comment should be fixed.
Thanks. I will change that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128899/new/

https://reviews.llvm.org/D128899



More information about the llvm-commits mailing list