[llvm] r370221 - [InstCombine] Disable recursion in foldGEPICmp for vector pointer GEPs

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 08:40:35 PDT 2019


Author: ctopper
Date: Wed Aug 28 08:40:34 2019
New Revision: 370221

URL: http://llvm.org/viewvc/llvm-project?rev=370221&view=rev
Log:
[InstCombine] Disable recursion in foldGEPICmp for vector pointer GEPs

Due to missing vector support in this function, recursion can
generate worse code in some cases.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Aug 28 08:40:34 2019
@@ -988,12 +988,14 @@ Instruction *InstCombiner::foldGEPICmp(G
     }
 
     // If one of the GEPs has all zero indices, recurse.
-    if (GEPLHS->hasAllZeroIndices())
+    // FIXME: Handle vector of pointers.
+    if (!GEPLHS->getType()->isVectorTy() && GEPLHS->hasAllZeroIndices())
       return foldGEPICmp(GEPRHS, GEPLHS->getOperand(0),
                          ICmpInst::getSwappedPredicate(Cond), I);
 
     // If the other GEP has all zero indices, recurse.
-    if (GEPRHS->hasAllZeroIndices())
+    // FIXME: Handle vector of pointers.
+    if (!GEPRHS->getType()->isVectorTy() && GEPRHS->hasAllZeroIndices())
       return foldGEPICmp(GEPLHS, GEPRHS->getOperand(0), Cond, I);
 
     bool GEPsInBounds = GEPLHS->isInBounds() && GEPRHS->isInBounds();

Modified: llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll Wed Aug 28 08:40:34 2019
@@ -110,6 +110,18 @@ define <2 x i1> @test6(<2 x i32> %X, <2
   ret <2 x i1> %C
 }
 
+; Same as above, but indices scalarized.
+define <2 x i1> @test6b(<2 x i32> %X, <2 x %S*> %P) nounwind {
+; CHECK-LABEL: @test6b(
+; CHECK-NEXT:    [[C:%.*]] = icmp eq <2 x i32> [[X:%.*]], <i32 1073741823, i32 1073741823>
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %A = getelementptr inbounds %S, <2 x %S*> %P, i32 0, i32 1, <2 x i32> %X
+  %B = getelementptr inbounds %S, <2 x %S*> %P, i32 0, i32 0
+  %C = icmp eq <2 x i32*> %A, %B
+  ret <2 x i1> %C
+}
+
 @G = external global [3 x i8]
 define i8* @test7(i16 %Idx) {
 ; CHECK-LABEL: @test7(




More information about the llvm-commits mailing list