[llvm] 6144085 - [IndVars] Don't widen pointers in WidenIV::getWideRecurrence

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 11 17:05:11 PDT 2021


Author: Eli Friedman
Date: 2021-07-11T17:04:50-07:00
New Revision: 6144085c29b31e8e43122920a5bfba3d7b77e7ae

URL: https://github.com/llvm/llvm-project/commit/6144085c29b31e8e43122920a5bfba3d7b77e7ae
DIFF: https://github.com/llvm/llvm-project/commit/6144085c29b31e8e43122920a5bfba3d7b77e7ae.diff

LOG: [IndVars] Don't widen pointers in WidenIV::getWideRecurrence

It's not a reasonable transform, and calling getSignExtendExpr() on a
pointer hits an assertion.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
    llvm/test/Transforms/IndVarSimplify/signed-trip-count.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index ff60667e72b3..bd30be011472 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1359,7 +1359,7 @@ WidenIV::getExtendedOperandRecurrence(WidenIV::NarrowIVDefUse DU) {
 /// so, return the extended recurrence and the kind of extension used. Otherwise
 /// return {nullptr, Unknown}.
 WidenIV::WidenedRecTy WidenIV::getWideRecurrence(WidenIV::NarrowIVDefUse DU) {
-  if (!SE->isSCEVable(DU.NarrowUse->getType()))
+  if (!DU.NarrowUse->getType()->isIntegerTy())
     return {nullptr, Unknown};
 
   const SCEV *NarrowExpr = SE->getSCEV(DU.NarrowUse);

diff  --git a/llvm/test/Transforms/IndVarSimplify/signed-trip-count.ll b/llvm/test/Transforms/IndVarSimplify/signed-trip-count.ll
index 41968ac05186..f660ea5bc9d9 100644
--- a/llvm/test/Transforms/IndVarSimplify/signed-trip-count.ll
+++ b/llvm/test/Transforms/IndVarSimplify/signed-trip-count.ll
@@ -1,7 +1,7 @@
 ; RUN: opt < %s -indvars -S | FileCheck %s
 
 ; Provide legal integer types.
-target datalayout = "n8:16:32:64"
+target datalayout = "e-p:32:32:32-n8:16:32:64"
 
 
 define void @foo(i64* nocapture %x, i32 %n) nounwind {


        


More information about the llvm-commits mailing list