[PATCH] D26169: [Reassociate] Skip reassociation for IV if its def instruction contains NSW/NUW flags to enable better IndVar and LSR

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 10:49:16 PST 2016


On Tue, Nov 8, 2016 at 8:07 PM, Mehdi AMINI <mehdi.amini at apple.com> wrote:
> mehdi_amini added a comment.
>
> What about having two modes for reassociate: one where we don't do any transformation that drop nsw/nuw flag, and another where it is permitted. Depending on the position in the pipeline we allow or not to drop the flags.
>

I don't know how much benefit we can get by calling reassociate twice.
It may need some experiments to answer. I expect the compile time cost
of reassoicate to be small.

But at least for the first reassociate pass, we cannot just drop all
the expr trees with nsw/nuw flag. We still need to restrict the skip
of reassociation only on values that can be represented as
SCEVAddRecExpr. Because otherwise for a[size+i+1] in loop i (adds in
array subscription expr are all with nsw flags), LSR will catch the
invariant promotion of "size+1" missed by LICM, but it cannot catch
other invariants inside exprs which are not induction value.

Thanks,
Wei.


More information about the llvm-commits mailing list