This is an archive of the discontinued LLVM Phabricator instance.

[Reassociate] Keep NSW/NUW flags on binary ops whenever possible.
AbandonedPublic

Authored by ab on Nov 3 2014, 10:44 AM.

Details

Summary

The previous - conservative - behavior was to always drop the overflow flags
when reassociating scalar expressions.

This kept address computing code done on int/i32 and sign-extended to i64,
because the nsw/nuw flags are needed to promote. In turn, this made it
impossible to fold the address computation into the addressing mode.

This (simple) patch tries to keep the nsw/nuw flags, but only when they are
consistent in the complete expression tree. My understanding is, this should be
valid, because the poison has to propagate to the root, no matter how the
expression is reassociated.
My reading of the rest of the code tells me the expression tree only consists of
the same operator, and all expressions have only one use.

Now for measurements:

Compile TimeΔPreviousCurrentσ
MultiSource/Benchmarks/ASC_Sequoia/IRSmk/IRSmk49.81%0.13210.19790.0005
SingleSource/Benchmarks/Misc/himenobmtxpa7.40%0.18390.19750.0009
Execution TimeΔPreviousCurrentσ
SingleSource/Benchmarks/Linpack/linpack-pc1.35%2.34032.37190.0033
MultiSource/Benchmarks/ASC_Sequoia/IRSmk/IRSmk-8.58%4.73864.33180.0052
SingleSource/Benchmarks/Misc/himenobmtxpa-5.91%1.62051.52480.0178
MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4-2.39%0.43020.41990.0011

I'm not exactly sure why linpack is slower; I'm (lightly) investigating, but can
look into it more seriously if people think it's a big deal?

Thanks,
-Ahmed

Diff Detail

Event Timeline

ab updated this revision to Diff 15720.Nov 3 2014, 10:44 AM
ab retitled this revision from to [Reassociate] Keep NSW/NUW flags on binary ops whenever possible..
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added reviewers: hfinkel, chandlerc, grosbach.
ab added a subscriber: Unknown Object (MLST).
ab updated this object.Nov 3 2014, 10:49 AM
ab updated this object.
mcrosier added a subscriber: mcrosier.
ab abandoned this revision.Nov 12 2014, 10:32 AM