[PATCH] D30689: [ConstantFolding] Small fix to prevent constant folding having to repeatedly scan operands.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 03:09:16 PST 2017


dmgreen created this revision.

We are seeing a case where after the unroll threshold was increased in
295538, a loop is fully unrolled into very large constant expression
chains. These are recursively scanned, leading to timeouts and hence
failures. This prevents having to rescan already scanned operands.


https://reviews.llvm.org/D30689

Files:
  lib/Analysis/ConstantFolding.cpp


Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -1058,8 +1058,8 @@
       if (It == FoldedOps.end()) {
         if (auto *FoldedC =
                 ConstantFoldConstantImpl(NewC, DL, TLI, FoldedOps)) {
-          NewC = FoldedC;
           FoldedOps.insert({NewC, FoldedC});
+          NewC = FoldedC;
         } else {
           FoldedOps.insert({NewC, NewC});
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30689.90827.patch
Type: text/x-patch
Size: 512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170307/44551598/attachment.bin>


More information about the llvm-commits mailing list