the nsw story, revisited

John,

Sanjoy,
Nuno,
David,
Thanks for the tip, below is a complete list and summary of every
thread in the archives with “nsw” in its subject line that I could find.

I am suggesting something similar to Dan’s third option below (Tue Nov 29 2011
"the nsw story”, Dan Gohman), when hoisting an instruction with ‘nsw’ it looses
the ‘nsw’ attribute, but without saying “add-nsw is a fully side-effecting
instruction”.

This option was back then seen by Dan as too much effort, but the current
proposal requires at least the same amount of effort. To be specific the
current proposal requires adding “freeze” instead of removing “nsw”. It is
pretty much the same amount of editing work on the compiler sources either
way as far as add/sub/mul/shl are concerned.

The difference is that removing “nsw” from an operation is simpler and cleaner
than adding “freeze” to it, and in software engineering we are always striving
for the simplest and cleanest solution.

IIUC option three does not inhibit Dan’s original goal of promoting 32-bit
induction variables to 64-bit on an LP64 target. And I don’t agree with Dan’s
description of this being “suboptimal” for any other reason, the lost
information does not seem to be useable AFAICT, but if you disagree then simply
insert an “llvm.assume" in the spot where the operation is being hoisted from.

So I propose that we revisit this option. It was never fully explored in Dan’s
original email, nor in any subsequent emails, and now especially it seems to
deserve it.

Thoughts ?
Comments ?
Questions ?

Peter Lawrence.