Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2019 07:04:59 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r354803 - in stable: 11/contrib/llvm/lib/Transforms/InstCombine 12/contrib/llvm/lib/Transforms/InstCombine
Message-ID:  <201911180704.xAI74xd5039987@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Mon Nov 18 07:04:59 2019
New Revision: 354803
URL: https://svnweb.freebsd.org/changeset/base/354803

Log:
  MFC r354724:
  
  Merge commit 5bbb604bb from llvm git (by Craig Topper):
  
    [InstCombine] Disable some portions of foldGEPICmp for GEPs that
    return a vector of pointers. Fix other portions.
  
    llvm-svn: 370114
  
  This should fix instances of 'Assertion failed: (isa<X>(Val) &&
  "cast<Ty>() argument of incompatible type!"), function cast, file
  /usr/src/contrib/llvm/include/llvm/Support/Casting.h, line 255', when
  building openjdk8 for aarch64 and armv7.
  
  Reported by:	jbeich
  PR:		236566

Modified:
  stable/12/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
==============================================================================
--- stable/12/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp	Mon Nov 18 04:22:04 2019	(r354802)
+++ stable/12/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp	Mon Nov 18 07:04:59 2019	(r354803)
@@ -830,6 +830,10 @@ getAsConstantIndexedAddress(Value *V, const DataLayout
 static Instruction *transformToIndexedCompare(GEPOperator *GEPLHS, Value *RHS,
                                               ICmpInst::Predicate Cond,
                                               const DataLayout &DL) {
+  // FIXME: Support vector of pointers.
+  if (GEPLHS->getType()->isVectorTy())
+    return nullptr;
+
   if (!GEPLHS->hasAllConstantIndices())
     return nullptr;
 
@@ -880,7 +884,9 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GE
     RHS = RHS->stripPointerCasts();
 
   Value *PtrBase = GEPLHS->getOperand(0);
-  if (PtrBase == RHS && GEPLHS->isInBounds()) {
+  // FIXME: Support vector pointer GEPs.
+  if (PtrBase == RHS && GEPLHS->isInBounds() &&
+      !GEPLHS->getType()->isVectorTy()) {
     // ((gep Ptr, OFFSET) cmp Ptr)   ---> (OFFSET cmp 0).
     // This transformation (ignoring the base and scales) is valid because we
     // know pointers can't overflow since the gep is inbounds.  See if we can
@@ -914,11 +920,13 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GE
       // If we're comparing GEPs with two base pointers that only differ in type
       // and both GEPs have only constant indices or just one use, then fold
       // the compare with the adjusted indices.
+      // FIXME: Support vector of pointers.
       if (GEPLHS->isInBounds() && GEPRHS->isInBounds() &&
           (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
           (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) &&
           PtrBase->stripPointerCasts() ==
-              GEPRHS->getOperand(0)->stripPointerCasts()) {
+              GEPRHS->getOperand(0)->stripPointerCasts() &&
+          !GEPLHS->getType()->isVectorTy()) {
         Value *LOffset = EmitGEPOffset(GEPLHS);
         Value *ROffset = EmitGEPOffset(GEPRHS);
 
@@ -962,15 +970,20 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GE
       unsigned DiffOperand = 0;     // The operand that differs.
       for (unsigned i = 1, e = GEPRHS->getNumOperands(); i != e; ++i)
         if (GEPLHS->getOperand(i) != GEPRHS->getOperand(i)) {
-          if (GEPLHS->getOperand(i)->getType()->getPrimitiveSizeInBits() !=
-                   GEPRHS->getOperand(i)->getType()->getPrimitiveSizeInBits()) {
+          Type *LHSType = GEPLHS->getOperand(i)->getType();
+          Type *RHSType = GEPRHS->getOperand(i)->getType();
+          // FIXME: Better support for vector of pointers.
+          if (LHSType->getPrimitiveSizeInBits() !=
+                   RHSType->getPrimitiveSizeInBits() ||
+              (GEPLHS->getType()->isVectorTy() &&
+               (!LHSType->isVectorTy() || !RHSType->isVectorTy()))) {
             // Irreconcilable differences.
             NumDifferences = 2;
             break;
-          } else {
-            if (NumDifferences++) break;
-            DiffOperand = i;
           }
+
+          if (NumDifferences++) break;
+          DiffOperand = i;
         }
 
       if (NumDifferences == 0)   // SAME GEP?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911180704.xAI74xd5039987>