blob: ea2cf8cf0ee04ff88768b23e51b78045707ab626 [file] [log] [blame]
Daniel Dunbar28897802008-11-12 12:31:28 +00001IRgen optimization opportunities.
2
3//===---------------------------------------------------------------------===//
4
5The common pattern of
6--
7short x; // or char, etc
8(x == 10)
9--
10generates an zext/sext of x which can easily be avoided.
11
12//===---------------------------------------------------------------------===//
13
14Bitfields accesses can be shifted to simplify masking and sign
15extension. For example, if the bitfield width is 8 and it is
16appropriately aligned then is is a lot shorter to just load the char
17directly.
18
19//===---------------------------------------------------------------------===//
Daniel Dunbare9095f52008-11-27 03:47:29 +000020
Daniel Dunbar2c4efe62008-12-04 09:05:45 +000021It may be worth avoiding creation of alloca's for formal arguments
22for the common situation where the argument is never written to or has
23its address taken. The idea would be to begin generating code by using
24the argument directly and if its address is taken or it is stored to
25then generate the alloca and patch up the existing code.
26
27In theory, the same optimization could be a win for block local
28variables as long as the declaration dominates all statements in the
29block.
30
31//===---------------------------------------------------------------------===//
32
Daniel Dunbar2f3a3d92009-02-20 19:34:45 +000033We should try and avoid generating basic blocks which only contain
34jumps. At -O0, this penalizes us all the way from IRgen (malloc &
35instruction overhead), all the way down through code generation and
36assembly time.
37
38On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just
39direct branches.
40
41//===---------------------------------------------------------------------===//
42
43There are some more places where we could avoid generating unreachable code. For
44example:
45 void f0(int a) { abort(); if (a) printf("hi"); }
46still generates a call to printf. This doesn't occur much in real
47code, but would still be nice to clean up.
48
49//===---------------------------------------------------------------------===//