Issue 174794
Summary LangRef icmp samesign clarification
Labels new issue
Assignees
Reporter Chobbes
    The `icmp` instruction has the following:

    If the samesign keyword is present and the operands are not of the same sign then the result is a [poison value](https://llvm.org/docs/LangRef.html#poisonvalues).

But in LLVM values themselves aren't really signed or unsigned, only the operations are. Because of this, I'm a little confused about what `samesign` actually means, and I was hoping we could clarify that 😅.

1. Does the `samesign` keyword only apply to the signed comparisons such as `sgt`, or does it also apply to the `ugt`?
2. If the `samesign` keyword applies to `ugt` as well, is the check on the signed interpretation of the numbers, or the unsigned interpretation?
3. What sign is `0` considered to have? Do `0` and `1` have the same sign? Does `0` and `-1` also have the same sign? Does `0` only share the same sign with itself?
4. Operations like `eq` and `ne` are somewhat different (there's only one version of these operations, and not separate ones for signed / unsigned). How does `samesign` work for these operations?

If we can clarify how `samesign` works I would be happy to update LangRef to reflect the discussion here.

Thanks!
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to