brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · e6d6109 Raw
48 lines · plain
1IRgen optimization opportunities.2 3//===---------------------------------------------------------------------===//4 5The common pattern of6--7short x; // or char, etc8(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 sign15extension. For example, if the bitfield width is 8 and it is16appropriately aligned then is is a lot shorter to just load the char17directly.18 19//===---------------------------------------------------------------------===//20 21It may be worth avoiding creation of alloca's for formal arguments22for the common situation where the argument is never written to or has23its address taken. The idea would be to begin generating code by using24the argument directly and if its address is taken or it is stored to25then generate the alloca and patch up the existing code.26 27In theory, the same optimization could be a win for block local28variables as long as the declaration dominates all statements in the29block.30 31NOTE: The main case we care about this for is for -O0 -g compile time32performance, and in that scenario we will need to emit the alloca33anyway currently to emit proper debug info. So this is blocked by34being able to emit debug information which refers to an LLVM35temporary, not an alloca.36 37//===---------------------------------------------------------------------===//38 39We should try and avoid generating basic blocks which only contain40jumps. At -O0, this penalizes us all the way from IRgen (malloc &41instruction overhead), all the way down through code generation and42assembly time.43 44On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just45direct branches!46 47//===---------------------------------------------------------------------===//48