[llvm] [X86] combine-sub-usat.ll - add test coverage inspired by #170076 (PR #170681)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 4 08:06:28 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/170681.diff
1 Files Affected:
- (modified) llvm/test/CodeGen/X86/combine-sub-usat.ll (+27)
``````````diff
diff --git a/llvm/test/CodeGen/X86/combine-sub-usat.ll b/llvm/test/CodeGen/X86/combine-sub-usat.ll
index 36e374bd2e67c..11eb363bb93f3 100644
--- a/llvm/test/CodeGen/X86/combine-sub-usat.ll
+++ b/llvm/test/CodeGen/X86/combine-sub-usat.ll
@@ -112,6 +112,33 @@ define <8 x i16> @combine_zero_v8i16(<8 x i16> %a0) {
ret <8 x i16> %1
}
+; fold (usub_sat x, 1) -> sub(x, zext(x != 0))
+define i32 @combine_dec_i32(i32 %a0) {
+; CHECK-LABEL: combine_dec_i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xorl %eax, %eax
+; CHECK-NEXT: subl $1, %edi
+; CHECK-NEXT: cmovael %edi, %eax
+; CHECK-NEXT: retq
+ %1 = call i32 @llvm.usub.sat.i32(i32 %a0, i32 1)
+ ret i32 %1
+}
+
+; fold (usub_sat x, 1) -> add(x, sext(x != 0))
+define <8 x i16> @combine_dec_v8i16(<8 x i16> %a0) {
+; SSE-LABEL: combine_dec_v8i16:
+; SSE: # %bb.0:
+; SSE-NEXT: psubusw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; SSE-NEXT: retq
+;
+; AVX-LABEL: combine_dec_v8i16:
+; AVX: # %bb.0:
+; AVX-NEXT: vpsubusw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; AVX-NEXT: retq
+ %1 = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %a0, <8 x i16> splat (i16 1))
+ ret <8 x i16> %1
+}
+
; fold (usub_sat x, x) -> 0
define i32 @combine_self_i32(i32 %a0) {
; CHECK-LABEL: combine_self_i32:
``````````
</details>
https://github.com/llvm/llvm-project/pull/170681
More information about the llvm-commits
mailing list