[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
Mon Jul 11 09:57:04 PDT 2022


msebor added a comment.

I see.  It's valid, for example, to `declare { i32, i32 } @div(i32, i32)` like the test does but that's not necessarily the same as the `div` declaration that Clang might emit for `div_t div(int, int)` on some targets.  This lets the test pass even on the same target as with an incompatible `div` and even though the corresponding C test would not (Clang would presumably issue `-Wincompatible-library-redeclaration`).  To catch these problems tests that exercise the C interface to a library would need to be written in C and ideally run for all supported targets.

I suppose one lesson here is that the functions that are handled in `SimplifyBuiltins.cpp` are treated as just ordinary functions, not as special intrinsics like they are in GCC where most of them have the same declarations across all targets and where it isn't possible to declare one that doesn't match.

Let me look into the idea of declaring `div` as a true intrinsic and see that simplifies things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129396



More information about the llvm-commits mailing list