[llvm] 2541b18 - [SLP]Mark and incompatible for 'xor %a, 0' operations

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 31 08:31:03 PST 2025


Author: Alexey Bataev
Date: 2025-12-31T08:30:50-08:00
New Revision: 2541b1870e7c90236b4010eec9a020c048f8beea

URL: https://github.com/llvm/llvm-project/commit/2541b1870e7c90236b4010eec9a020c048f8beea
DIFF: https://github.com/llvm/llvm-project/commit/2541b1870e7c90236b4010eec9a020c048f8beea.diff

LOG: [SLP]Mark and incompatible for 'xor %a, 0' operations

Xor with 0 is incompatible with and, which resulst in all zero instead
of %a

https://alive2.llvm.org/ce/z/oEVETS

Fixes #174041

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
    llvm/test/Transforms/SLPVectorizer/X86/xor-with-zero-and-incompat.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 56f8188112d88..3d98d470387e8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1217,7 +1217,7 @@ class BinOpSameOpcodeHelper {
         break;
       case Instruction::Xor:
         if (CIValue.isZero())
-          InterchangeableMask = XorBIT | OrBIT | AndBIT | SubBIT | AddBIT;
+          InterchangeableMask = XorBIT | OrBIT | SubBIT | AddBIT;
         break;
       default:
         if (CIValue.isZero())

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/xor-with-zero-and-incompat.ll b/llvm/test/Transforms/SLPVectorizer/X86/xor-with-zero-and-incompat.ll
index 545470ebed9f1..ad6c3c77a2e11 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/xor-with-zero-and-incompat.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/xor-with-zero-and-incompat.ll
@@ -6,7 +6,7 @@ define void @src_test_xor_and_identity_mismatch(i32 %a, i32 %b, ptr %dst) {
 ; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]], ptr [[DST:%.*]]) {
 ; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i32> poison, i32 [[A]], i32 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <2 x i32> [[TMP1]], i32 [[B]], i32 1
-; CHECK-NEXT:    [[TMP3:%.*]] = and <2 x i32> [[TMP2]], <i32 0, i32 -1>
+; CHECK-NEXT:    [[TMP3:%.*]] = xor <2 x i32> [[TMP2]], zeroinitializer
 ; CHECK-NEXT:    store <2 x i32> [[TMP3]], ptr [[DST]], align 4
 ; CHECK-NEXT:    ret void
 ;


        


More information about the llvm-commits mailing list