[llvm] Removed expansive copy (PR #93658)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 01:35:47 PDT 2024


https://github.com/JaydeepChauhan14 created https://github.com/llvm/llvm-project/pull/93658

Removed expansive copy.

There are two calls for method **isBlendOrUndef** in file **llvm/lib/Target/X86/X86ISelLowering.cpp** , 
1.  For NewBlendMask it is allocating 32*4=>128 Bytes
```
...
SmallVector<int, 32> NewBlendMask(NumElts, SM_SentinelUndef);
...
assert(isBlendOrUndef(NewBlendMask) && "Bad blend"); 
...
```

2. For BlendMask it is allocating 16*4=> 64 Bytes
```
...
    SmallVector<int, 16> BlendMask;
    DecodeBLENDMask(NumElts, Op.getConstantOperandVal(2), BlendMask);
    if (SDValue R = combineBlendOfPermutes(
            VT.getSimpleVT(), Op.getOperand(0), Op.getOperand(1), BlendMask,
            DemandedElts, TLO.DAG, Subtarget, SDLoc(Op)))
      return TLO.CombineTo(Op, R);
...
assert(isBlendOrUndef(BlendMask) && "Blend shuffle expected");
...
```
- Both above cases are allocating 64 and 128 bytes. which is looks expansive, So removed copy. 

>From 7ed7003881c2466fd3c2c7e1b3a541efc49bd3cb Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai <chauhan.jaydeep.ashwinbhai at intel.com>
Date: Wed, 29 May 2024 16:24:57 +0800
Subject: [PATCH] Removed expansive copy

---
 llvm/lib/Target/X86/X86ISelLowering.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 2d8343ffa1a0b..c240b4fa6b599 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3588,7 +3588,7 @@ static bool isUndefOrZeroOrInRange(ArrayRef<int> Mask, int Low, int Hi) {
 /// undef.
 LLVM_ATTRIBUTE_UNUSED static bool isBlendOrUndef(ArrayRef<int> Mask) {
   unsigned NumElts = Mask.size();
-  for (auto [I, M] : enumerate(Mask))
+  for (auto &[I, M] : enumerate(Mask))
     if (!isUndefOrEqual(M, I) && !isUndefOrEqual(M, I + NumElts))
       return false;
   return true;



More information about the llvm-commits mailing list