tstellar / rpms / llvm

Forked from rpms/llvm 5 years ago
Clone
93d2074
From 2eb830fed5b813c5624e770c244eec61dacb04d7 Mon Sep 17 00:00:00 2001
93d2074
From: Tom Stellard <tstellar@redhat.com>
93d2074
Date: Mon, 9 Jul 2018 10:35:30 -0700
93d2074
Subject: [PATCH] Don't run BV DAG Combine before legalization if it assumes
93d2074
 legal types
93d2074
93d2074
---
93d2074
 lib/Target/PowerPC/PPCISelLowering.cpp | 13 ++++++++++---
93d2074
 1 file changed, 10 insertions(+), 3 deletions(-)
93d2074
93d2074
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
93d2074
index 26e9f13..f622b05 100644
93d2074
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
93d2074
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
93d2074
@@ -11790,10 +11790,15 @@ static SDValue combineBVOfVecSExt(SDNode *N, SelectionDAG &DAG) {
93d2074
   auto isSExtOfVecExtract = [&](SDValue Op) -> bool {
93d2074
     if (!Op)
93d2074
       return false;
93d2074
-    if (Op.getOpcode() != ISD::SIGN_EXTEND)
93d2074
+    if (Op.getOpcode() != ISD::SIGN_EXTEND &&
93d2074
+        Op.getOpcode() != ISD::SIGN_EXTEND_INREG)
93d2074
       return false;
93d2074
 
93d2074
+    // A SIGN_EXTEND_INREG might be fed by an ANY_EXTEND to produce a value
93d2074
+    // of the right width.
93d2074
     SDValue Extract = Op.getOperand(0);
93d2074
+    if (Extract.getOpcode() == ISD::ANY_EXTEND)
93d2074
+      Extract = Extract.getOperand(0);
93d2074
     if (Extract.getOpcode() != ISD::EXTRACT_VECTOR_ELT)
93d2074
       return false;
93d2074
 
93d2074
@@ -11881,8 +11886,10 @@ SDValue PPCTargetLowering::DAGCombineBuildVector(SDNode *N,
93d2074
     return Reduced;
93d2074
 
93d2074
   // If we're building a vector out of extended elements from another vector
93d2074
-  // we have P9 vector integer extend instructions.
93d2074
-  if (Subtarget.hasP9Altivec()) {
93d2074
+  // we have P9 vector integer extend instructions. The code assumes legal
93d2074
+  // input types (i.e. it can't handle things like v4i16) so do not run before
93d2074
+  // legalization.
93d2074
+  if (Subtarget.hasP9Altivec() && !DCI.isBeforeLegalize()) {
93d2074
     Reduced = combineBVOfVecSExt(N, DAG);
93d2074
     if (Reduced)
93d2074
       return Reduced;
93d2074
-- 
93d2074
1.8.3.1
93d2074