This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Simplify trunc-of-add/mul to add/mul-of-trunc under more circumstances.
ClosedPublic

Authored by jlebar on Jun 13 2018, 8:37 PM.

Details

Summary

Previously we would do this simplification only if it did not introduce
any new truncs (excepting new truncs which replace other cast ops).

This change weakens this condition: If the number of truncs stays the
same, but we're able to transform trunc(X + Y) to X + trunc(Y), that's
still simpler, and it may open up additional transformations.

While we're here, also clean up some duplicated code.

Event Timeline

jlebar created this revision.Jun 13 2018, 8:37 PM
sanjoy accepted this revision.Jun 14 2018, 9:41 AM

lgtm

This revision is now accepted and ready to land.Jun 14 2018, 9:41 AM
This revision was automatically updated to reflect the committed changes.

Hi @jlebar

This patch seems to cause the bug https://bugs.llvm.org/show_bug.cgi?id=39160 on vectorization stage. See reproducer in the bug.

Note that I have taken a look into your patch and don't see any obvious problems in that; it is likely to expose some underlying bug rather than introduce a new one, but it's not for sure.

I'm going to investigate it tomorrow. I'd appreciate if you could take a look into it or revert the patch until its reason is clear.

Thanks,
Max