[PATCH] [X86] Updates to X86 backend for f16 promotion

Pirama Arumuga Nainar pirama at google.com
Tue Apr 28 19:39:26 PDT 2015


================
Comment at: lib/Target/X86/X86ISelLowering.cpp:17317-17321
@@ -17311,2 +17316,7 @@
   case ISD::FP_TO_SINT:
+    // FP_TO_INT*_IN_MEM is not legal for f16 inputs.  Do not convert
+    // (FP_TO_SINT (load f16)) to FP_TO_INT*.
+    if (N->getOperand(0).getValueType() == MVT::f16)
+      break;
+    // fallthrough in the false-branch
   case ISD::FP_TO_UINT: {
----------------
ab wrote:
> Why isn't this in the FP_TO_UINT block?  Either way, please add uitofp/fptoui tests.
This block is needed only for FP_TO_SINT with i64 return.  OperationAction is set to custom around line 217:

```
  setOperationAction(ISD::FP_TO_SINT     , MVT::i64  , Custom);
  setOperationAction(ISD::SINT_TO_FP     , MVT::i64  , Custom);
```

I'll add a test for uitofp and fptoui.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:17367-17373
@@ -17356,2 +17366,9 @@
   }
+  case ISD::FP_EXTEND: {
+    // Right now, only MVT::v2f32 has OperationAction for FP_EXTEND.
+    // No other ValueType for FP_EXTEND should reach this point.
+    assert(N->getValueType(0) == MVT::v2f32 &&
+           "Do not know how to legalize this Node");
+    return;
+  }
   case ISD::INTRINSIC_W_CHAIN: {
----------------
ab wrote:
> Does v2f32 even hit this?  Without this patch it should trigger the default unreachable, why would that change?
Around line 924 in this file:

```
setOperationAction(ISD::FP_EXTEND,          MVT::v2f32, Custom);
```
is what necessitates this.  v2f32 will be a valuetype of an FP_EXTEND node only when the source type is smaller (i.e. v2f16).  I am not sure why the OperationAction is set as above, but it triggers the unreachable error for FP_EXTEND from v2f16.  The included test for vec4 extend fails because vec4 is split during legalization.  Now that I think about it, I should add a vec2 test so this test doesn't rot if vec4 is legal in the future.

http://reviews.llvm.org/D9092

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list