[llvm] [DAGCombiner] Fold smax(X, -1) to or(X, ashr(X, BW-1)) for code size (PR #206242)
Aayush Shrivastava via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 28 01:00:54 PDT 2026
================
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=x86_64-linux -O2 | FileCheck %s
+;
+; Verify smax(X, -1) and smin(X, 0) fold to bitwise shift forms.
+; smax(X, -1) = or(X, ashr(X, BW-1)) -- saves a byte vs compare+cmov on x86-64
+; smin(X, 0) = and(X, ashr(X, BW-1)) -- saves a byte vs compare+cmov on x86-64
+; Both also reduce instruction count on AArch64/APX. GCC PR 125921, LLVM #206153.
----------------
iamaayushrivastava wrote:
Done. Deleted `smax-allones-codesize.ll` and moved the scalar smax tests into `combine-smax.ll` and the smin tests into `combine-smin.ll`. Thanks!
https://github.com/llvm/llvm-project/pull/206242
More information about the llvm-commits
mailing list