[llvm] [AMDGPU] Replace `isInlinableLiteral16` with specific version (PR #81345)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 07:59:06 PST 2024


================
@@ -4121,8 +4121,27 @@ bool SIInstrInfo::isInlineConstant(const APInt &Imm) const {
                                         ST.hasInv2PiInlineImm());
   case 16:
     return ST.has16BitInsts() &&
-           AMDGPU::isInlinableLiteral16(Imm.getSExtValue(),
-                                        ST.hasInv2PiInlineImm());
+           AMDGPU::isInlinableLiteralI16(Imm.getSExtValue(),
+                                         ST.hasInv2PiInlineImm());
+  default:
+    llvm_unreachable("invalid bitwidth");
+  }
+}
+
+bool SIInstrInfo::isInlineConstant(const APFloat &Imm) const {
+  APInt IntImm = Imm.bitcastToAPInt();
+  bool HasInv2Pi = ST.hasInv2PiInlineImm();
+  switch (IntImm.getBitWidth()) {
+  case 32:
+  case 64:
+    return isInlineConstant(IntImm);
+  case 16:
+    if (Imm.isIEEE())
+      return ST.has16BitInsts() &&
+             AMDGPU::isInlinableLiteralFP16(IntImm.getSExtValue(), HasInv2Pi);
+    else
+      return ST.has16BitInsts() &&
+             AMDGPU::isInlinableLiteralBF16(IntImm.getSExtValue(), HasInv2Pi);
----------------
arsenm wrote:

can be one big return statement 

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


More information about the llvm-commits mailing list