Hans Wennborg
395f4f4b2a
Switch lowering: extract jump tables and bit tests before building binary tree (PR22262)
...
This is a re-commit of r235101, which also fixes the problems with the previous patch:
- Switches with only a default case and non-fallthrough were handled incorrectly
- The previous patch tickled a bug in PowerPC Early-Return Creation which is fixed here.
> This is a major rewrite of the SelectionDAG switch lowering. The previous code
> would lower switches as a binary tre, discovering clusters of cases
> suitable for lowering by jump tables or bit tests as it went along. To increase
> the likelihood of finding jump tables, the binary tree pivot was selected to
> maximize case density on both sides of the pivot.
>
> By not selecting the pivot in the middle, the binary trees would not always
> be balanced, leading to performance problems in the generated code.
>
> This patch rewrites the lowering to search for clusters of cases
> suitable for jump tables or bit tests first, and then builds the binary
> tree around those clusters. This way, the binary tree will always be balanced.
>
> This has the added benefit of decoupling the different aspects of the lowering:
> tree building and jump table or bit tests finding are now easier to tweak
> separately.
>
> For example, this will enable us to balance the tree based on profile info
> in the future.
>
> The algorithm for finding jump tables is quadratic, whereas the previous algorithm
> was O(n log n) for common cases, and quadratic only in the worst-case. This
> doesn't seem to be major problem in practice, e.g. compiling a file consisting
> of a 10k-case switch was only 30% slower, and such large switches should be rare
> in practice. Compiling e.g. gcc.c showed no compile-time difference. If this
> does turn out to be a problem, we could limit the search space of the algorithm.
>
> This commit also disables all optimizations during switch lowering in -O0.
>
> Differential Revision: http://reviews.llvm.org/D8649
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235560 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-22 23:14:56 +00:00
..
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:29:02 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-02-13 14:44:26 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 19:29:02 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 19:29:02 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-05-27 15:57:51 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:29:02 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-03-17 14:50:32 +00:00
2014-10-19 21:29:21 +00:00
2015-02-27 19:29:02 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2014-12-15 19:07:53 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-17 14:50:32 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-03-19 22:48:57 +00:00
2015-01-06 16:46:37 +00:00
2015-02-27 21:17:42 +00:00
2014-12-15 19:07:53 +00:00
2014-06-13 14:24:07 +00:00
2015-04-11 13:40:36 +00:00
2015-02-27 21:17:42 +00:00
2014-10-03 18:04:36 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-07-18 23:29:49 +00:00
2015-02-27 21:17:42 +00:00
2014-10-31 10:33:14 +00:00
2015-01-01 02:53:29 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-01-21 20:15:58 +00:00
2015-02-27 21:17:42 +00:00
2014-12-04 00:46:20 +00:00
2015-01-03 01:16:37 +00:00
2015-01-03 01:16:37 +00:00
2013-11-30 19:39:27 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-01-05 03:41:38 +00:00
2014-10-17 01:41:22 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-03-13 18:20:45 +00:00
2013-12-16 21:24:00 +00:00
2014-03-02 18:23:39 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-04 20:44:33 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-02-16 13:27:39 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2014-02-25 20:51:50 +00:00
2015-02-27 21:17:42 +00:00
2015-03-27 20:46:33 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-09 23:54:37 +00:00
2015-04-09 23:54:37 +00:00
2015-02-27 21:17:42 +00:00
2014-12-15 19:07:53 +00:00
2015-04-22 23:14:56 +00:00
2015-04-20 00:01:30 +00:00
2015-03-05 18:55:50 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-10 03:39:00 +00:00
2014-10-19 21:29:21 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 18:32:11 +00:00
2015-04-04 02:26:47 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 18:32:11 +00:00
2015-02-27 21:17:42 +00:00
2014-10-17 01:41:22 +00:00
2014-11-24 23:45:21 +00:00
2014-03-23 05:35:00 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-20 20:29:40 +00:00
2015-04-20 20:29:40 +00:00
2014-10-21 13:02:37 +00:00
2014-10-19 20:27:56 +00:00
2014-10-21 23:01:01 +00:00
2014-10-21 23:01:01 +00:00
2014-10-19 21:29:21 +00:00
2014-02-28 00:27:01 +00:00
2014-10-19 21:29:21 +00:00
2014-10-19 21:29:21 +00:00
2015-04-11 10:40:42 +00:00
2015-02-27 21:17:42 +00:00
2015-01-06 06:01:57 +00:00
2014-06-23 13:47:52 +00:00
2014-12-26 16:42:47 +00:00
2014-06-23 13:47:52 +00:00
2015-02-27 21:17:42 +00:00
2014-10-17 01:41:22 +00:00
2014-10-17 01:41:22 +00:00
2014-06-16 21:36:02 +00:00
2015-02-27 21:17:42 +00:00
2014-07-04 10:57:56 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-25 19:36:23 +00:00
2015-01-05 21:10:24 +00:00
2014-03-05 22:14:00 +00:00
2014-03-23 05:35:00 +00:00
2014-10-19 21:29:21 +00:00
2014-03-23 05:35:00 +00:00
2015-02-27 21:17:42 +00:00
2015-01-13 19:43:45 +00:00
2015-01-13 19:43:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-02-13 15:33:35 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2013-11-30 19:39:27 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-06-09 22:42:55 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-04-10 15:05:02 +00:00
2015-02-27 21:17:42 +00:00
2015-04-12 17:18:56 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-19 02:40:56 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-17 01:41:22 +00:00
2015-04-22 23:14:56 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-17 01:41:22 +00:00
2015-02-27 21:17:42 +00:00
2015-04-15 15:59:37 +00:00
2015-04-22 23:14:56 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:58:28 +00:00
2015-03-31 20:35:26 +00:00
2015-03-31 20:56:09 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:29:02 +00:00
2015-03-13 18:20:45 +00:00
2015-03-13 18:20:45 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2015-02-01 15:03:28 +00:00
2015-02-01 15:03:28 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2015-02-27 21:17:42 +00:00
2015-02-12 01:02:52 +00:00
2015-02-27 21:17:42 +00:00
2014-02-28 00:27:01 +00:00
2015-04-01 00:40:48 +00:00
2015-02-27 21:17:42 +00:00
2015-02-01 17:52:16 +00:00
2015-04-11 00:33:08 +00:00
2015-02-27 21:17:42 +00:00
2014-12-03 00:19:17 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2013-11-30 19:39:27 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-06-23 12:36:34 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-17 06:45:15 +00:00
2015-02-27 18:32:11 +00:00
2015-01-18 12:08:47 +00:00
2015-01-19 07:20:27 +00:00
2015-02-27 21:17:42 +00:00
2015-01-14 20:17:10 +00:00
2015-01-14 20:17:10 +00:00
2015-03-05 19:47:50 +00:00
2015-01-15 21:17:34 +00:00
2015-04-16 23:24:18 +00:00
2014-08-23 23:21:04 +00:00
2015-02-01 15:03:28 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-03-05 19:47:50 +00:00
2014-12-11 22:51:06 +00:00
2015-03-13 18:20:45 +00:00
2015-01-25 18:05:42 +00:00
2014-07-21 00:03:18 +00:00
2015-03-05 18:55:50 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-02 22:34:22 +00:00
2015-03-21 03:36:02 +00:00
2015-03-26 00:57:33 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-03-13 18:20:45 +00:00
2015-03-13 18:20:45 +00:00
2014-07-31 19:50:53 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 23:29:57 +00:00
2015-04-22 11:32:25 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-25 01:06:45 +00:00
2015-02-25 01:06:45 +00:00
2015-02-25 01:26:59 +00:00
2015-02-27 21:17:42 +00:00
2015-02-25 01:06:45 +00:00
2015-02-25 01:06:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-25 01:26:59 +00:00
2015-02-27 21:17:42 +00:00
2015-03-23 08:22:43 +00:00
2015-02-25 01:26:59 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-21 13:02:37 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-04-16 23:24:18 +00:00
2015-03-13 18:20:45 +00:00
2015-02-10 19:09:05 +00:00
2015-02-27 21:17:42 +00:00
2014-12-16 05:51:41 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-17 01:41:22 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2014-02-28 00:27:01 +00:00
2014-12-23 08:38:50 +00:00
2014-11-12 15:16:30 +00:00
2014-02-28 00:27:01 +00:00
2014-02-28 00:27:01 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2014-01-28 05:32:58 +00:00
2014-05-27 15:57:51 +00:00
2015-02-27 21:17:42 +00:00
2013-11-20 01:10:15 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 19:29:02 +00:00
2015-03-13 18:20:45 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 19:29:02 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-06-23 13:47:52 +00:00
2015-03-13 18:20:45 +00:00
2015-02-27 21:17:42 +00:00
2015-02-25 21:36:59 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2015-04-16 23:24:18 +00:00
2014-10-17 15:13:38 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-10-19 21:29:21 +00:00
2015-03-03 17:24:31 +00:00
2015-02-27 21:17:42 +00:00
2015-04-16 23:24:18 +00:00
2015-02-27 21:17:42 +00:00
2015-03-14 01:43:57 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-05 15:24:47 +00:00
2014-08-04 13:13:57 +00:00
2015-03-03 19:55:45 +00:00
2015-04-03 13:48:24 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-03 19:55:45 +00:00
2015-02-27 21:17:42 +00:00
2015-03-10 19:49:38 +00:00
2015-03-10 19:49:38 +00:00
2015-02-27 21:17:42 +00:00
2015-02-04 20:00:04 +00:00
2015-03-05 16:24:38 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-08-04 14:55:26 +00:00
2015-02-20 15:54:58 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-06-05 22:57:38 +00:00
2015-04-03 10:02:21 +00:00
2014-10-19 21:29:21 +00:00
2015-02-12 22:43:52 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-12-05 20:32:05 +00:00
2015-02-27 21:17:42 +00:00
2015-03-27 06:10:13 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2014-12-05 20:32:05 +00:00
2015-04-16 23:24:18 +00:00
2014-12-05 20:32:05 +00:00
2015-02-27 21:17:42 +00:00
2014-03-14 12:45:22 +00:00
2015-02-27 21:17:42 +00:00
2015-02-18 16:21:46 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00