Chandler Carruth f103b3d1b9 Teach the X86 instruction selection to do some heroic transforms to
detect a pattern which can be implemented with a small 'shl' embedded in
the addressing mode scale. This happens in real code as follows:

  unsigned x = my_accelerator_table[input >> 11];

Here we have some lookup table that we look into using the high bits of
'input'. Each entity in the table is 4-bytes, which means this
implicitly gets turned into (once lowered out of a GEP):

  *(unsigned*)((char*)my_accelerator_table + ((input >> 11) << 2));

The shift right followed by a shift left is canonicalized to a smaller
shift right and masking off the low bits. That hides the shift right
which x86 has an addressing mode designed to support. We now detect
masks of this form, and produce the longer shift right followed by the
proper addressing mode. In addition to saving a (rather large)
instruction, this also reduces stalls in Intel chips on benchmarks I've
measured.

In order for all of this to work, one part of the DAG needs to be
canonicalized *still further* than it currently is. This involves
removing pointless 'trunc' nodes between a zextload and a zext. Without
that, we end up generating spurious masks and hiding the pattern.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147936 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-11 08:41:08 +00:00
..
2011-04-15 00:32:41 +00:00
2011-07-02 20:43:08 +00:00
2011-07-02 20:42:53 +00:00
2011-01-16 18:02:57 +00:00
2011-03-09 22:07:31 +00:00
2011-06-19 12:14:34 +00:00
2011-03-08 20:19:10 +00:00
2011-10-22 12:39:25 +00:00
2011-10-30 13:24:22 +00:00
2011-11-23 04:03:08 +00:00
2011-01-16 18:02:57 +00:00
2011-09-30 23:40:29 +00:00
2011-09-30 23:21:11 +00:00
2011-08-09 03:04:23 +00:00
2012-01-05 00:43:34 +00:00
2012-01-05 00:43:34 +00:00
2011-08-19 04:30:24 +00:00
2011-08-27 04:53:41 +00:00
2011-07-02 20:42:36 +00:00
2011-05-26 18:00:32 +00:00
2011-07-02 20:42:33 +00:00
2011-04-25 10:12:01 +00:00
2011-01-01 21:58:41 +00:00
2011-11-15 07:13:03 +00:00
2011-04-17 02:36:27 +00:00
2011-02-16 01:08:31 +00:00
2011-03-23 23:11:02 +00:00
2011-07-02 20:42:25 +00:00
2011-03-11 21:52:04 +00:00
2011-11-08 00:09:27 +00:00
2011-08-31 21:41:20 +00:00
2011-11-12 20:35:26 +00:00
2011-06-02 20:02:48 +00:00
2011-11-22 06:36:25 +00:00
2011-12-08 19:21:39 +00:00
2011-07-20 03:09:11 +00:00
2011-01-16 18:02:57 +00:00
2011-10-16 20:43:41 +00:00
2011-03-23 23:11:02 +00:00
2011-07-26 22:45:39 +00:00
2011-06-14 23:47:36 +00:00
2011-11-15 07:13:03 +00:00
2011-11-07 23:10:43 +00:00
2011-11-08 00:03:24 +00:00
2011-11-07 19:15:58 +00:00
2011-02-20 12:37:50 +00:00
2011-10-10 23:18:02 +00:00
2011-11-16 03:03:52 +00:00
2010-12-20 20:10:50 +00:00
2011-11-07 19:15:58 +00:00
2011-03-11 21:52:04 +00:00