[llvm] [InstCombine][Docs] Update InstCombine contributor guide (PR #144228)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 15 04:13:54 PDT 2025


================
@@ -404,11 +404,31 @@ The use of TargetTransformInfo is only allowed for hooks for target-specific
 intrinsics, such as `TargetTransformInfo::instCombineIntrinsic()`. These are
 already inherently target-dependent anyway.
 
+If some canonicalization narrow/widen the integer width of expressions, please
+check `shouldChangeType()` first. Otherwise, we may evaluate the expression 
+in illegal/inefficient types. For vector types, follow the instructions below.
+
 For vector-specific transforms that require cost-modelling, the VectorCombine
 pass can be used instead. In very rare circumstances, if there are no other
 alternatives, target-dependent transforms may be accepted into
 AggressiveInstCombine.
 
+Generally, we prefer unsigned operations over signed operations in the middle-end, even
+if signed operations are more efficient on some targets. The following is an incomplete
+list of canonicalizations that implemented in InstCombine:
+
+| Original Pattern             | Canonical Form     | Condition                     |
+|------------------------------|--------------------|-------------------------------|
+| `icmp spred X, Y`            | `icmp upred X, Y`  | `sign(X) == sign(Y)`          |
----------------
artagnon wrote:

I thought the motivation for the samesign effort was to avoid canonicalizations like this, so that the back-end can choose?

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


More information about the llvm-commits mailing list