This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] Add support for non-uniform vectors to BuildSDIV
ClosedPublic

Authored by RKSimon on Aug 15 2018, 4:40 AM.

Details

Summary

This patch refactors the existing TargetLowering::BuildSDIV base implementation to support non-uniform constant vector denominators.

This is the last patch necessary to close PR36545

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Aug 15 2018, 4:40 AM

Would it be possible to split this into a NFC refactoring and leave here just the change to actually enable the vector support?

lebedev.ri accepted this revision.Aug 16 2018, 10:17 AM

Thanks, looks almost NFC to me.

lib/CodeGen/SelectionDAG/TargetLowering.cpp
3530–3531 ↗(On Diff #161051)

We will end up with improperly-sized/indexed arrays.
I understand that / 0 is ub, but i wonder if we should be more proactive in failing?
Perhaps we should push 0, 0, 0 to the vectors. Or maybe the current way is sufficient.

This revision is now accepted and ready to land.Aug 16 2018, 10:17 AM
RKSimon added inline comments.Aug 16 2018, 10:26 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
3530–3531 ↗(On Diff #161051)

Any division by zero (even if its just one element in a vector) results in UNDEF - but we don't want to handle it here - so we just bail and leave DAGCombiner's simplifyDivRem to handle it.

lebedev.ri added inline comments.Aug 16 2018, 10:28 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
3553–3555 ↗(On Diff #161051)

Oh right, if BuildSDIVPattern() returned false, we exit here, right.

This revision was automatically updated to reflect the committed changes.