This is an archive of the discontinued LLVM Phabricator instance.

[Codegen][SelectionDAG] X u% C == 0 fold: non-splat vectors, accept power-of-two constants
AbandonedPublic

Authored by lebedev.ri on Jun 28 2019, 7:10 AM.

Details

Summary

Three things here:

  1. Generalize the fold to handle non-splat divisors. Reasonably trivial.
  2. Unban power-of-two divisors. I don't see any reason why they should be illegal.
    • There is no ban in Hacker's Delight
    • I think the ban came from the same bug that caused the miscompile - in floor((2^W - 1) / D) we were dividing by D0 instead of D, and we were ensuring that D0 is not 1, which makes sense.
    • We are correct to ban 1 divisor - we'd have setule/setugt N, all-ones i.e. the remainder of division by 1 is 0 for any N, which is bogus.
    • 1 divisor is banned in Hacker's Delight
  3. Be careful to not fold if there is at least one 1 divisor.

Diff Detail

Repository
rL LLVM