[llvm] [InstCombine] Fold -X / -Y -> X / Y (PR #88422)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 11:59:58 PDT 2024


AtariDreams wrote:

> Is there any real-world motivation for these transforms?

Absolutely.

Negation of divisor and dividend are common when working with macros especially in older C code back when constexpr were not a thing and offsets were calculated via:

...

#define X_START  0
#define Y_START = 0

int distanceFromX = X_START - x;
int distanceFromY = Y_START - y;

int rate = distanceFromY/distanceFromX

Yes, I know that a lot of code doesn't look like this anymore, but for a lot of software this was pretty much how it looked.


https://github.com/llvm/llvm-project/pull/88422


More information about the llvm-commits mailing list