diff options
author | Xiang1 Zhang <xiang1.zhang@intel.com> | 2022-06-30 19:07:25 +0800 |
---|---|---|
committer | Xiang1 Zhang <xiang1.zhang@intel.com> | 2022-07-01 08:58:00 +0800 |
commit | 5fe5aa284efed1ee1492e1f266351b35f0a8bb69 (patch) | |
tree | 9127ff30cd1b550821aa903b12f81d149372197c /llvm/lib/Support/APInt.cpp | |
parent | 4be3fc35aa8b27494968e9a52eb0afa0672d98e7 (diff) | |
download | llvm-5fe5aa284efed1ee1492e1f266351b35f0a8bb69.zip llvm-5fe5aa284efed1ee1492e1f266351b35f0a8bb69.tar.gz llvm-5fe5aa284efed1ee1492e1f266351b35f0a8bb69.tar.bz2 |
[ISel] Match all bits when merge undef(s) for DAG combine
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index acc68fe..f74178b 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -2968,7 +2968,8 @@ llvm::APIntOps::GetMostSignificantDifferentBit(const APInt &A, const APInt &B) { return A.getBitWidth() - ((A ^ B).countLeadingZeros() + 1); } -APInt llvm::APIntOps::ScaleBitMask(const APInt &A, unsigned NewBitWidth) { +APInt llvm::APIntOps::ScaleBitMask(const APInt &A, unsigned NewBitWidth, + bool MatchAllBits) { unsigned OldBitWidth = A.getBitWidth(); assert((((OldBitWidth % NewBitWidth) == 0) || ((NewBitWidth % OldBitWidth) == 0)) && @@ -2992,11 +2993,16 @@ APInt llvm::APIntOps::ScaleBitMask(const APInt &A, unsigned NewBitWidth) { if (A[i]) NewA.setBits(i * Scale, (i + 1) * Scale); } else { - // Merge bits - if any old bit is set, then set scale equivalent new bit. unsigned Scale = OldBitWidth / NewBitWidth; - for (unsigned i = 0; i != NewBitWidth; ++i) - if (!A.extractBits(Scale, i * Scale).isZero()) - NewA.setBit(i); + for (unsigned i = 0; i != NewBitWidth; ++i) { + if (MatchAllBits) { + if (A.extractBits(Scale, i * Scale).isAllOnes()) + NewA.setBit(i); + } else { + if (!A.extractBits(Scale, i * Scale).isZero()) + NewA.setBit(i); + } + } } return NewA; |