Skip to content

Conversation

@davemgreen
Copy link
Collaborator

The abd nodes do not perform the same as abs(x-y), although they are often mistaken to do so. They extend into a larger bit size before performing the sub / abs and so produce different results. Update the description of the instruction to avoid misunderstandings.

The abd nodes do not perform the same as abs(x-y), although they are often
mistaken to do so. They extend into a larger bit size before performing the sub
/ abs. Update the description of the instruction to avoid misunderstandings.
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2025

@llvm/pr-subscribers-llvm-globalisel

Author: David Green (davemgreen)

Changes

The abd nodes do not perform the same as abs(x-y), although they are often mistaken to do so. They extend into a larger bit size before performing the sub / abs and so produce different results. Update the description of the instruction to avoid misunderstandings.


Full diff: https://github.com/llvm/llvm-project/pull/164594.diff

1 Files Affected:

  • (modified) llvm/docs/GlobalISel/GenericOpcode.rst (+1-1)
diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst
index b055327466739..661a11537cf57 100644
--- a/llvm/docs/GlobalISel/GenericOpcode.rst
+++ b/llvm/docs/GlobalISel/GenericOpcode.rst
@@ -504,7 +504,7 @@ undefined.
 G_ABDS, G_ABDU
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Compute the absolute difference (signed and unsigned), e.g. abs(x-y).
+Compute the absolute difference (signed and unsigned), e.g. trunc(abs(ext(x)-ext(y)).
 
 .. code-block:: none
 

@davemgreen davemgreen merged commit 57412c3 into llvm:main Oct 22, 2025
13 checks passed
@davemgreen davemgreen deleted the gh-a64-abddesc branch October 22, 2025 12:20
@AZero13
Copy link
Contributor

AZero13 commented Oct 22, 2025

The abd nodes do not perform the same as abs(x-y), although they are often mistaken to do so. They extend into a larger bit size before performing the sub / abs and so produce different results. Update the description of the instruction to avoid misunderstandings.

I mean thet do if x - y does not overflow. But yeah.

dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
The abd nodes do not perform the same as abs(x-y), although they are
often mistaken to do so. They extend into a larger bit size before
performing the sub / abs and so produce different results. Update the
description of the instruction to avoid misunderstandings.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
The abd nodes do not perform the same as abs(x-y), although they are
often mistaken to do so. They extend into a larger bit size before
performing the sub / abs and so produce different results. Update the
description of the instruction to avoid misunderstandings.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
The abd nodes do not perform the same as abs(x-y), although they are
often mistaken to do so. They extend into a larger bit size before
performing the sub / abs and so produce different results. Update the
description of the instruction to avoid misunderstandings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants