This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Support non-uniform X%C -> X-(X/C)*C folds
ClosedPublic

Authored by RKSimon on Jul 5 2018, 8:53 AM.

Details

Summary

First stage in PR38057 - support non-uniform constant vectors in the combine to reuse the division-by-constant logic.

We can definitely do better for srem pow2 remainders (and avoid that extra multiply....) but this at least helps keep everything on the vector unit.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Jul 5 2018, 8:53 AM
efriedma added inline comments.Jul 5 2018, 10:41 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3285–3289

Instead of doing this weird recursive combine() dance, can we just call BuildSDIV() or whatever directly? Not exactly part of your patch, but it's difficult to follow what code actually runs here, and it only gets more complicated with vectors.

RKSimon added inline comments.Jul 5 2018, 11:17 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3285–3289

Almost certainly - I'll look at what is involved.

efriedma accepted this revision.Jul 10 2018, 11:58 AM

LGTM. (The code generation isn't perfect, but the required changes are orthogonal, I think.)

This revision is now accepted and ready to land.Jul 10 2018, 11:58 AM
This revision was automatically updated to reflect the committed changes.