Skip to content

Commit c2a1966

Browse files
committed
[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.
1 parent fe83acc commit c2a1966

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -437,29 +437,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
437437
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
438438
break;
439439
}
440-
case Instruction::BitCast:
441-
if (!I->getOperand(0)->getType()->isIntOrIntVectorTy())
442-
return nullptr; // vector->int or fp->int?
443-
444-
if (auto *DstVTy = dyn_cast<VectorType>(VTy)) {
445-
if (auto *SrcVTy = dyn_cast<VectorType>(I->getOperand(0)->getType())) {
446-
if (isa<ScalableVectorType>(DstVTy) ||
447-
isa<ScalableVectorType>(SrcVTy) ||
448-
cast<FixedVectorType>(DstVTy)->getNumElements() !=
449-
cast<FixedVectorType>(SrcVTy)->getNumElements())
450-
// Don't touch a bitcast between vectors of different element counts.
451-
return nullptr;
452-
} else
453-
// Don't touch a scalar-to-vector bitcast.
454-
return nullptr;
455-
} else if (I->getOperand(0)->getType()->isVectorTy())
456-
// Don't touch a vector-to-scalar bitcast.
457-
return nullptr;
458-
459-
if (SimplifyDemandedBits(I, 0, DemandedMask, Known, Depth + 1))
460-
return I;
461-
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
462-
break;
463440
case Instruction::SExt: {
464441
// Compute the bits in the result that are not present in the input.
465442
unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits();

llvm/test/Transforms/InstCombine/icmp-vec.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,8 @@ define i1 @eq_cast_zext(<5 x i3> %b) {
649649

650650
define i1 @sgt_cast_zext(<5 x i3> %b) {
651651
; CHECK-LABEL: @sgt_cast_zext(
652-
; CHECK-NEXT: [[E:%.*]] = zext <5 x i3> [[B:%.*]] to <5 x i7>
653-
; CHECK-NEXT: [[BC:%.*]] = bitcast <5 x i7> [[E]] to i35
654-
; CHECK-NEXT: [[R:%.*]] = icmp sgt i35 [[BC]], 0
652+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast <5 x i3> [[B:%.*]] to i15
653+
; CHECK-NEXT: [[R:%.*]] = icmp ne i15 [[TMP1]], 0
655654
; CHECK-NEXT: ret i1 [[R]]
656655
;
657656
%e = zext <5 x i3> %b to <5 x i7>

0 commit comments

Comments
 (0)