This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Split `WidenIV::cloneIVUser`; NFC
ClosedPublic

Authored by sanjoy on Oct 13 2015, 7:48 PM.

Details

Summary

This NFC splitting is intended to make a later diff easier to follow.
It just tail duplicates cloneIVUser into cloneArithmeticIVUser and
cloneBitwiseIVUser.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 37314.Oct 13 2015, 7:48 PM
sanjoy retitled this revision from to [IndVars] Split `WidenIV::cloneIVUser`; NFC.
sanjoy updated this object.
sanjoy added reviewers: atrick, hfinkel, reames.
sanjoy added a subscriber: llvm-commits.
reames edited edge metadata.Oct 14 2015, 12:18 PM

I'm a bit confused by the need/desirability of this change. Isn't it fairly simple to make the special case for widening conditional on the operator type within a single function? Or is there something more fundamental I'm missing?

I'm a bit confused by the need/desirability of this change. Isn't it fairly simple to make the special case for widening conditional on the operator type within a single function? Or is there something more fundamental I'm missing?

Firstly, the structure of cloneArithmeticIVUser will end up being a little different from cloneBitwiseIVUser; and I think having an "early dispatch" will make it easier to avoid bugs. This is the practical reason why I split the two.

There is a more fundamental difference between the two as well, which I've not drawn attention to here, because it isn't being used -- SCEV is usually to unable to analyze bitwise operations like x & y (unless they're just optimized arithmetic). This means we don't widen uses of IVs like and %iv, 42 (and insert a trunc) even though bitwise operations are (almost by definition) easy to widen (zext (and %iv, 42) == and zext(%iv), zext(42)). -instcombine is usually able to clean these (the trunc s) up, but if we later find interesting cases that -instcombine cannot clean up then we could make cloneBitwiseIVUser smarter, which would further diverge the implementations.

reames accepted this revision.Oct 15 2015, 3:26 PM
reames edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 15 2015, 3:26 PM
This revision was automatically updated to reflect the committed changes.