[llvm] [X86][GlobalIsel] Add support for G_UMIN/G_UMAX/G_SMIN/G_SMAX (PR #160247)

Evgenii Kudriashov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 10:06:27 PDT 2025


================
@@ -147,6 +147,11 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
         });
   }
 
+  getActionDefinitionsBuilder({G_UMIN, G_UMAX, G_SMIN, G_SMAX})
+      .widenScalarToNextPow2(0, /*Min=*/32)
+      .clampScalar(0, s8, s64)
----------------
e-kud wrote:

I think that I could be wrong here. For scalars we always lower it into `cmp+select`. Maybe we should have just `lower()` here, and `cmp+select` will be responsible for the correct types. Currently `narrowScalar` is not implemented for `G_{U,S}{MIN,MAX}` and it's not clear whether we can implement it more efficient than doing each operation in narrowed types. SDAG also lowers it into `i64` `setcc+select` on `i686`.
What do you think @RKSimon?

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


More information about the llvm-commits mailing list