[llvm-commits] [llvm-testresults] lab-mini-01__O3-plain__clang_DEV__x86_64 test results

Andrew Trick atrick at apple.com
Tue May 29 14:10:34 PDT 2012


On May 26, 2012, at 12:39 AM, Duncan Sands <baldrick at free.fr> wrote:
> I didn't mention it in the commit log, but the new version is much less
> destructive and tries harder to preserve nsw flags: if the rewritten
> expression is the same as the original (modulo trivial changes) then all
> nsw etc flags are preserved.  The previous version would only preserve
> flags if the expression involved only one operation (eg: a+b, not a+b+c).
> The old pass would drop all uses of leaves by writing undef into the parent's
> operands; the new version only writes in an undef in order to force a tree
> topology onto the expression, for example if there is a diamond use pattern
> then one leg of the diamond gets zapped.  If the expression already has the
> form reassociate creates (a linear sequence of operations) or in fact has any
> form that is a tree then there is no destruction at this stage.  When writing
> out the new optimized expression (which is written in place in top of the old)
> that makes it easy to tell if you are actually changing anything: compare the
> new operands with the old ones, which are still all present now.  The rewriting
> stage takes care to ensure that if the original expression was already in the
> desired form then literally no changes are made when writing out the new.

Brilliant! I don't understand your code in detail yet, but it looks like a major step in the right direction.

We still have some work do to do teach Reassociate about flags. One of the test cases I was looking at drops flags in a few cases:

1. shl nsw x, c => mul x, 2**c
2. sub nsw x, y => add x, (sub 0, y)
3. add nsw (add nsw x, c1), c2 ; where c1 and c2 have opposite signs.

Filed http://llvm.org/pr12985

Another option is running Reassociate twice: before indvars while preserving flags, and after indvars for full-on reassociation. But I doubt it's worth adding that complexity to the pipeline.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120529/79b7fcfa/attachment.html>


More information about the llvm-commits mailing list