[PATCH] D77033: [Legalizer] Workaround for scalarizing unary strict-fp ops

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 21:56:48 PDT 2020


qiucf created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
qiucf added a parent revision: D64193: [PowerPC] Add exception constraint to FP rounding operations.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77033

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -215,14 +215,29 @@
   // The Chain is the first operand.
   Opers[0] = Chain;
 
-  // Now process the remaining operands.
-  for (unsigned i = 1; i < NumOpers; ++i) {
-    SDValue Oper = N->getOperand(i);
+  if (NumOpers == 2) {
+    SDValue Oper = N->getOperand(1);
+    EVT OpVT = Oper.getValueType();
 
-    if (Oper.getValueType().isVector())
+    // The result needs scalarizing, but it's not a given that the source does.
+    if (getTypeAction(OpVT) == TargetLowering::TypeScalarizeVector)
       Oper = GetScalarizedVector(Oper);
+    else {
+      EVT VT = OpVT.getVectorElementType();
+      Oper = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, VT, Oper,
+                         DAG.getVectorIdxConstant(0, dl));
+    }
+    Opers[1] = Oper;
+  } else {
+    // Now process the remaining operands.
+    for (unsigned i = 1; i < NumOpers; ++i) {
+      SDValue Oper = N->getOperand(i);
 
-    Opers[i] = Oper;
+      if (Oper.getValueType().isVector())
+        Oper = GetScalarizedVector(Oper);
+
+      Opers[i] = Oper;
+    }
   }
 
   SDValue Result = DAG.getNode(N->getOpcode(), dl, DAG.getVTList(ValueVTs),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77033.253488.patch
Type: text/x-patch
Size: 1367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200330/d35c69da/attachment-0001.bin>


More information about the llvm-commits mailing list