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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 07:12:13 PDT 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: RKSimon, hermord, craig.topper, spatel, xbolva00.
lebedev.ri added a project: LLVM.
Herald added subscribers: dexonsmith, javed.absar.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D63930

Files:
  include/llvm/CodeGen/TargetLowering.h
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  test/CodeGen/AArch64/urem-seteq-vec-nonsplat.ll
  test/CodeGen/X86/urem-seteq-vec-nonsplat.ll
  unittests/ADT/APIntTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63930.207057.patch
Type: text/x-patch
Size: 28433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190628/a61cc19a/attachment.bin>


More information about the llvm-commits mailing list