Skip to content

Commit 65f3359

Browse files
committedApr 26, 2015
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. llvm-svn: 235825
1 parent 20c24f1 commit 65f3359

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
 

‎llvm/docs/Frontend/PerformanceTips.rst

+17-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ Other things to consider
5555

5656
#. Add nsw/nuw flags as appropriate. Reasoning about overflow is
5757
generally hard for an optimizer so providing these facts from the frontend
58-
can be very impactful. For languages which need overflow semantics,
59-
consider using the :ref:`overflow intrinsics <int_overflow>`.
58+
can be very impactful.
6059

6160
#. Use fast-math flags on floating point operations if legal. If you don't
6261
need strict IEEE floating point semantics, there are a number of additional
@@ -142,6 +141,22 @@ Other things to consider
142141
perform badly with confronted with such structures. The only exception to
143142
this guidance is that a unified return block with high in-degree is fine.
144143

144+
#. When checking a value against a constant, emit the check using a consistent
145+
comparison type. The GVN pass _will_ optimize redundant equalities even if
146+
the type of comparison is inverted, but GVN only runs late in the pipeline.
147+
As a result, you may miss the oppurtunity to run other important
148+
optimizations. Improvements to EarlyCSE to remove this issue are tracked in
149+
Bug 23333.
150+
151+
#. Avoid using arithmetic intrinsics unless you are _required_ by your source
152+
language specification to emit a particular code sequence. The optimizer
153+
is quite good at reasoning about general control flow and arithmetic, it is
154+
not anywhere near as strong at reasoning about the various intrinsics. If
155+
profitable for code generation purposes, the optimizer will likely form the
156+
intrinsics itself late in the optimization pipeline. It is _very_ rarely
157+
profitable to emit these directly in the language frontend. This item
158+
explicitly includes the use of the :ref:`overflow intrinsics <int_overflow>`.
159+
145160
p.s. If you want to help improve this document, patches expanding any of the
146161
above items into standalone sections of their own with a more complete
147162
discussion would be very welcome.

0 commit comments

Comments
 (0)