[PATCH] D129396: [InstCombine] Add support for div, ldiv, lldiv, and imaxdiv folding

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 13:04:24 PDT 2022


msebor updated this revision to Diff 453754.
msebor added a comment.
Herald added subscribers: pcwang-thead, luke957, sstefan1, s.egerton, simoncook, fedor.sergeev.
Herald added a reviewer: jdoerfert.

Revision 2 with the following changes:

- Enhance the signature validation to cover known forms for all supported targets.
- Likewise, enhance the folder code to handle all known forms of the function signatures.
- Add tests.
- Adjust `TargetLibraryInfoTest.cpp` to cover the functions.

I manually verified the sanity of the approach with a number of targets representative of the recognized forms of the function declaration and tried to capture them all in the comprehensive tests.  The patch passes all tests on x86_64-linux with one failure:

  Failed Tests (1):
    LLVM :: tools/llvm-tli-checker/ps4-tli-check.yaml

I can guess the failure has to do with what's hardcoded somewhere for the `ps4` target but not much more.  There's a comment in `ps4-tli-check.yaml` that reads:

  ## The -COUNT suffix doesn't care if there are too many matches, so check
  ## the exact count first; the two directives should add up to that.
  ## Yes, this means additions to TLI will fail this test, but the argument
  ## to -COUNT can't be an expression.

There's no suggestion on how the failure should be fixed in this instance and nothing I tried worked (e.g., the simple approach from D114881 <https://reviews.llvm.org/D114881>) so I'm afraid I'll need some handholding here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129396/new/

https://reviews.llvm.org/D129396

Files:
  llvm/include/llvm/Analysis/TargetLibraryInfo.def
  llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/test/Transforms/InstCombine/div-1.ll
  llvm/test/Transforms/InstCombine/div-2.ll
  llvm/test/Transforms/InstCombine/div-3.ll
  llvm/test/Transforms/InstCombine/div-4.ll
  llvm/unittests/Analysis/TargetLibraryInfoTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129396.453754.patch
Type: text/x-patch
Size: 94807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220818/c38bbcc5/attachment-0001.bin>


More information about the llvm-commits mailing list