[llvm] Optimized Constant Xor And And Not Operation (PR #161784)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 05:50:57 PDT 2025


================
@@ -0,0 +1,80 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=-bmi < %s | FileCheck %s --check-prefixes=CHECK,NOBMI
+; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefixes=CHECK,BMI
+
+; Test the optimization described in issue #161630:
+; (Constant XOR a) & b & ~c should compile to allow andn to be done in parallel with xor
+
+define i64 @test_constant_xor_and_andnot(i64 %a, i64 %b, i64 %c) {
+; CHECK-LABEL: test_constant_xor_and_andnot:
+; CHECK:       # %bb.0:
+; NOBMI-NEXT:    movq %rdx, %rax
+; CHECK-NEXT:    xorq $1234, %rdi # imm = 0x4D2
+; NOBMI-NEXT:    andq %rsi, %rdi
+; NOBMI-NEXT:    notq %rax
+; NOBMI-NEXT:    andq %rdi, %rax
+; BMI-NEXT:      andnq %rsi, %rdx, %rax
+; BMI-NEXT:      andq %rdi, %rax
+; CHECK-NEXT:    retq
----------------
RKSimon wrote:

this doesn't look like update_llc_test_checks generated test checks

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


More information about the llvm-commits mailing list