[DAGCombiner] Poor DAG combining with alias analysis turned on.

Jonas Paulsson jonas.paulsson at ericsson.com
Mon Feb 9 07:38:18 PST 2015


Hi,

I have a test case with an unrolled loop body, consisting of a long sequence of non-overlapping stores. I found that with alias analysis it became very compile time expensive (53 seconds, without AA it was 0.02 sec). The program spent a lot of time in WalkChainUsers() (isel), and it was due to all the token factor nodes introduced by the combiner.

I spent some time looking into it, and found that nearly all of the compile time disappeared if the combiner added a new token factor node to the worklist. The case was that there was a mess of token factors at the bottom of the DAG, that disappeared after reiteration over those nodes.

Test case supplied, to run: llc -mtriple=arm -combiner-alias-analysis unrolledloop.opt.ll

I supply a patch for this. Let me know if this seems reasonable to use and if I can commit.

/Jonas Paulsson


Patch:

>From 0123157edefc2aea3137b702b1fa24ebd41e7709 Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <jonas.paulsson at ericsson.com>
Date: Mon, 9 Feb 2015 16:19:53 +0100
Subject: [PATCH] Fix SelectionDAG compile time issue with alias analysis.

Add new token factor node to worklist if alias analysis is turned on,
in DAGCombiner::visitTokenFactor().
---
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8a4b602..dbf6ef7 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1539,8 +1539,10 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) {
       Result = DAG.getNode(ISD::TokenFactor, SDLoc(N), MVT::Other, Ops);
     }
-    // Don't add users to work list.
-    return CombineTo(N, Result, false);
+    // Don't add users to work list, unless alias analysis is used.
+    bool UseAA = CombinerAA.getNumOccurrences() > 0 ? CombinerAA
+      : DAG.getSubtarget().useAA();
+    return CombineTo(N, Result, UseAA /*add to worklist*/);
   }
   return Result;
--
1.8.4.2



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150209/64563a24/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-SelectionDAG-compile-time-issue-with-alias-analy.patch
Type: application/octet-stream
Size: 1175 bytes
Desc: 0001-Fix-SelectionDAG-compile-time-issue-with-alias-analy.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150209/64563a24/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unrolledloop.opt.ll
Type: application/octet-stream
Size: 5545 bytes
Desc: unrolledloop.opt.ll
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150209/64563a24/attachment-0001.obj>


More information about the llvm-commits mailing list