[llvm-bugs] [Bug 35890] New: SCEV expander assertion in LSR

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 10 10:05:02 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=35890

            Bug ID: 35890
           Summary: SCEV expander assertion in LSR
           Product: tools
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: anna at azul.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19648
  --> https://bugs.llvm.org/attachment.cgi?id=19648&action=edit
input IR to pass with -loop-reduce

With the following bugpoint code attached, llvm trunk (without rL321550)
crashes when trying to retrieve a PostIncExpr because the PostIncExpr is not an
AddRecurrence. 

rL321550 limits the depth in recursive call to getAddRec because we were
missing passing the depth.

I think the change only hides the actual problem in SCEV because limiting the
recursion depth is only a compile time restriction and not a functional
requirement. Is this correct?


Command to use:
opt -loop-reduce reduced.ll

Trunk with the following diff [1] still crashes with assertion failure:
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!")
when trying to cast the result of getAddRec into SCEVAddRecExpr:
#4  0x00007ffff5147dcc in llvm::cast<llvm::SCEVAddRecExpr, llvm::SCEV const> () 


Diff to apply is basically the revert of rL321550:
diff --git a/lib/Analysis/ScalarEvolution.cpp
b/lib/Analysis/ScalarEvolution.cpp
index 10b5c74e378..32fd05d2ea4 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -2358,7 +2358,7 @@ const SCEV
*ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
       FoundMatch = true;
     }
   if (FoundMatch)
-    return getAddExpr(Ops, Flags, Depth + 1);
+    return getAddExpr(Ops, Flags);

   // Check for truncates. If all the operands are truncated from the same
   // type, see if factoring out the truncate would permit the result to be

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180110/0ed2604b/attachment.html>


More information about the llvm-bugs mailing list