[llvm] [APInt] Introduce signed-gcd APIntOps (PR #217269)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 00:54:36 PDT 2026


https://github.com/nikic commented:

I'm a bit unclear on what the semantics of this API are even supposed to be.

It seems like your interpretation of `sgcd(2, -2)` is `-2`, but ... why? -2 is not "greater" than 2 under any reasonable interpretation.

My expectation would probably be the sgcd always returns the positive value as gcd. Basically `sgcd(x, y) = gcd(abs(x), abs(y))`.

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


More information about the llvm-commits mailing list