[llvm] [X86] setcc-logic.ll - add i128 cmpeq(or(X,Y),X) --> cmpeq(and(~X,Y),0) test (PR #185289)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 08:36:58 PDT 2026


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/185289

Inspired by #157687

>From d294fe788b41c6de9c96766b5aec3e0ed2701da6 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Sun, 8 Mar 2026 15:35:45 +0000
Subject: [PATCH] [X86] setcc-logic.ll - add i128 cmpeq(or(X,Y),X) -->
 cmpeq(and(~X,Y),0) test

Inspired by #157687
---
 llvm/test/CodeGen/X86/setcc-logic.ll | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/llvm/test/CodeGen/X86/setcc-logic.ll b/llvm/test/CodeGen/X86/setcc-logic.ll
index c98aae7fbf405..3572d046bace7 100644
--- a/llvm/test/CodeGen/X86/setcc-logic.ll
+++ b/llvm/test/CodeGen/X86/setcc-logic.ll
@@ -625,6 +625,29 @@ define i1 @and_icmps_const_1bit_diff_common_op(i32 %x, i32 %y) {
 
 ; PR44136 - fold cmpeq(or(X,Y),X) --> cmpeq(and(~X,Y),0)
 
+define i1 @or_cmp_eq_i128(i128 %x, i128 %y) {
+; NOBMI-LABEL: or_cmp_eq_i128:
+; NOBMI:       # %bb.0:
+; NOBMI-NEXT:    notq %rsi
+; NOBMI-NEXT:    andq %rcx, %rsi
+; NOBMI-NEXT:    notq %rdi
+; NOBMI-NEXT:    andq %rdx, %rdi
+; NOBMI-NEXT:    orq %rsi, %rdi
+; NOBMI-NEXT:    sete %al
+; NOBMI-NEXT:    retq
+;
+; BMI-LABEL: or_cmp_eq_i128:
+; BMI:       # %bb.0:
+; BMI-NEXT:    andnq %rcx, %rsi, %rax
+; BMI-NEXT:    andnq %rdx, %rdi, %rcx
+; BMI-NEXT:    orq %rax, %rcx
+; BMI-NEXT:    sete %al
+; BMI-NEXT:    retq
+  %o = or i128 %x, %y
+  %c = icmp eq i128 %o, %x
+  ret i1 %c
+}
+
 define i1 @or_cmp_eq_i64(i64 %x, i64 %y) {
 ; NOBMI-LABEL: or_cmp_eq_i64:
 ; NOBMI:       # %bb.0:



More information about the llvm-commits mailing list