[llvm] c2a1966 - [InstCombine] Remove bitcast handling from SimplifyDemandedBits
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 06:25:48 PST 2023
Author: Nikita Popov
Date: 2023-11-10T15:25:39+01:00
New Revision: c2a1966627aa45b3afa5d21758a983c56434ae23
URL: https://github.com/llvm/llvm-project/commit/c2a1966627aa45b3afa5d21758a983c56434ae23
DIFF: https://github.com/llvm/llvm-project/commit/c2a1966627aa45b3afa5d21758a983c56434ae23.diff
LOG: [InstCombine] Remove bitcast handling from SimplifyDemandedBits
The complex set of type checks in this code reduces down to
"always return nullptr". Drop the code to use the default
implementation instead, which will just compute the KnownBits
for the bitcast.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/icmp-vec.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 29cf04d82b2e401..15d9886216b292a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -437,29 +437,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
break;
}
- case Instruction::BitCast:
- if (!I->getOperand(0)->getType()->isIntOrIntVectorTy())
- return nullptr; // vector->int or fp->int?
-
- if (auto *DstVTy = dyn_cast<VectorType>(VTy)) {
- if (auto *SrcVTy = dyn_cast<VectorType>(I->getOperand(0)->getType())) {
- if (isa<ScalableVectorType>(DstVTy) ||
- isa<ScalableVectorType>(SrcVTy) ||
- cast<FixedVectorType>(DstVTy)->getNumElements() !=
- cast<FixedVectorType>(SrcVTy)->getNumElements())
- // Don't touch a bitcast between vectors of
diff erent element counts.
- return nullptr;
- } else
- // Don't touch a scalar-to-vector bitcast.
- return nullptr;
- } else if (I->getOperand(0)->getType()->isVectorTy())
- // Don't touch a vector-to-scalar bitcast.
- return nullptr;
-
- if (SimplifyDemandedBits(I, 0, DemandedMask, Known, Depth + 1))
- return I;
- assert(!Known.hasConflict() && "Bits known to be one AND zero?");
- break;
case Instruction::SExt: {
// Compute the bits in the result that are not present in the input.
unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits();
diff --git a/llvm/test/Transforms/InstCombine/icmp-vec.ll b/llvm/test/Transforms/InstCombine/icmp-vec.ll
index ddc60ee0ce41939..f4db2db2a99b643 100644
--- a/llvm/test/Transforms/InstCombine/icmp-vec.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-vec.ll
@@ -649,9 +649,8 @@ define i1 @eq_cast_zext(<5 x i3> %b) {
define i1 @sgt_cast_zext(<5 x i3> %b) {
; CHECK-LABEL: @sgt_cast_zext(
-; CHECK-NEXT: [[E:%.*]] = zext <5 x i3> [[B:%.*]] to <5 x i7>
-; CHECK-NEXT: [[BC:%.*]] = bitcast <5 x i7> [[E]] to i35
-; CHECK-NEXT: [[R:%.*]] = icmp sgt i35 [[BC]], 0
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast <5 x i3> [[B:%.*]] to i15
+; CHECK-NEXT: [[R:%.*]] = icmp ne i15 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%e = zext <5 x i3> %b to <5 x i7>
More information about the llvm-commits
mailing list