annotate clang/lib/CodeGen/README.txt @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 IRgen optimization opportunities.
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 //===---------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 The common pattern of
anatofuz
parents:
diff changeset
6 --
anatofuz
parents:
diff changeset
7 short x; // or char, etc
anatofuz
parents:
diff changeset
8 (x == 10)
anatofuz
parents:
diff changeset
9 --
anatofuz
parents:
diff changeset
10 generates an zext/sext of x which can easily be avoided.
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 //===---------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 Bitfields accesses can be shifted to simplify masking and sign
anatofuz
parents:
diff changeset
15 extension. For example, if the bitfield width is 8 and it is
anatofuz
parents:
diff changeset
16 appropriately aligned then is is a lot shorter to just load the char
anatofuz
parents:
diff changeset
17 directly.
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 //===---------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 It may be worth avoiding creation of alloca's for formal arguments
anatofuz
parents:
diff changeset
22 for the common situation where the argument is never written to or has
anatofuz
parents:
diff changeset
23 its address taken. The idea would be to begin generating code by using
anatofuz
parents:
diff changeset
24 the argument directly and if its address is taken or it is stored to
anatofuz
parents:
diff changeset
25 then generate the alloca and patch up the existing code.
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 In theory, the same optimization could be a win for block local
anatofuz
parents:
diff changeset
28 variables as long as the declaration dominates all statements in the
anatofuz
parents:
diff changeset
29 block.
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 NOTE: The main case we care about this for is for -O0 -g compile time
anatofuz
parents:
diff changeset
32 performance, and in that scenario we will need to emit the alloca
anatofuz
parents:
diff changeset
33 anyway currently to emit proper debug info. So this is blocked by
anatofuz
parents:
diff changeset
34 being able to emit debug information which refers to an LLVM
anatofuz
parents:
diff changeset
35 temporary, not an alloca.
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 //===---------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 We should try and avoid generating basic blocks which only contain
anatofuz
parents:
diff changeset
40 jumps. At -O0, this penalizes us all the way from IRgen (malloc &
anatofuz
parents:
diff changeset
41 instruction overhead), all the way down through code generation and
anatofuz
parents:
diff changeset
42 assembly time.
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just
anatofuz
parents:
diff changeset
45 direct branches!
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 //===---------------------------------------------------------------------===//