[llvm] [DAG] Support saturated truncate (PR #99418)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 00:03:28 PDT 2024


================
@@ -804,6 +804,9 @@ enum NodeType {
 
   /// TRUNCATE - Completely drop the high bits.
   TRUNCATE,
+  /// TRUNCATE_[SU]SAT - Truncate for saturated operand
+  TRUNCATE_SSAT,
----------------
topperc wrote:

Variables don't have signed or unsigned type but operations can interpret their input as signed or unsigned.

I believe as you have defined it TRUNCATE_USAT will interpret the input as an unsigned value and produce an unsigned result in the destination type.

The x86 packuswb interprets the input as signed 16 bits and produces an unsigned 8 bit result. If the input is negative it will return 0. That is a different operation than either operation defined here. It's equivalent to smax with 0 followed by truncate_usat. I could imagine having that operation as a single node. Not suggesting for this patch.

I just want the semantics of the new opcodes documented.

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


More information about the llvm-commits mailing list