llvm.org GIT mirror llvm / 7745680
Add two new items to PerformanceTips 1) Turns out we're not great at recognizing redundant checks when one is a != and the other is an ==. This is a bug, but it's one that matters to frontend authors. 2) Frontends shouldn't use intrinsics unless strictly neccessary. This has been pretty widely proven by this point and is good to document. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235825 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 4 years ago
1 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
5454
5555 #. Add nsw/nuw flags as appropriate. Reasoning about overflow is
5656 generally hard for an optimizer so providing these facts from the frontend
57 can be very impactful. For languages which need overflow semantics,
58 consider using the :ref:`overflow intrinsics `.
57 can be very impactful.
5958
6059 #. Use fast-math flags on floating point operations if legal. If you don't
6160 need strict IEEE floating point semantics, there are a number of additional
141140 perform badly with confronted with such structures. The only exception to
142141 this guidance is that a unified return block with high in-degree is fine.
143142
143 #. When checking a value against a constant, emit the check using a consistent
144 comparison type. The GVN pass _will_ optimize redundant equalities even if
145 the type of comparison is inverted, but GVN only runs late in the pipeline.
146 As a result, you may miss the oppurtunity to run other important
147 optimizations. Improvements to EarlyCSE to remove this issue are tracked in
148 Bug 23333.
149
150 #. Avoid using arithmetic intrinsics unless you are _required_ by your source
151 language specification to emit a particular code sequence. The optimizer
152 is quite good at reasoning about general control flow and arithmetic, it is
153 not anywhere near as strong at reasoning about the various intrinsics. If
154 profitable for code generation purposes, the optimizer will likely form the
155 intrinsics itself late in the optimization pipeline. It is _very_ rarely
156 profitable to emit these directly in the language frontend. This item
157 explicitly includes the use of the :ref:`overflow intrinsics `.
158
144159 p.s. If you want to help improve this document, patches expanding any of the
145160 above items into standalone sections of their own with a more complete
146161 discussion would be very welcome.