[llvm] [X86] Fix XOR folding in EmitCmp (PR #210546)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 19 08:57:48 PDT 2026


================
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=X64
+
+define zeroext i1 @foo(ptr %x) {
+; X86-LABEL: foo:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    xorl $7, (%eax)
+; X86-NEXT:    setne %al
+; X86-NEXT:    retl
+;
+; X64-LABEL: foo:
+; X64:       # %bb.0:
+; X64-NEXT:    xorl $7, (%rdi)
+; X64-NEXT:    setne %al
+; X64-NEXT:    retq
+  %1 = load i32, ptr %x
+  %2 = xor i32 %1, 7
+  store i32 %2, ptr %x
+  %tobool.not = icmp ne i32 %1, 7
+  ret i1 %tobool.not
+}
----------------
RKSimon wrote:

add this to cmp-xor.ll instead of creating a new test file? its need a better name (xor_cmp_rmw_i32?) and you should avoid using numbered variables.

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


More information about the llvm-commits mailing list