Skip to content

Commit e299a42

Browse files
committed
[ConstantFold] Remove redundant bitcast icmp handling (NFCI)
This code excludes vector/scalar and FP bitcasts. All other integer/pointer bitcasts are no-op bitcasts and will be removed entirely.
1 parent 9915eba commit e299a42

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

llvm/lib/IR/ConstantFold.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,20 +1451,6 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
14511451
if (Result != -1)
14521452
return ConstantInt::get(ResultTy, Result);
14531453

1454-
// If the right hand side is a bitcast, try using its inverse to simplify
1455-
// it by moving it to the left hand side. We can't do this if it would turn
1456-
// a vector compare into a scalar compare or visa versa, or if it would turn
1457-
// the operands into FP values.
1458-
if (ConstantExpr *CE2 = dyn_cast<ConstantExpr>(C2)) {
1459-
Constant *CE2Op0 = CE2->getOperand(0);
1460-
if (CE2->getOpcode() == Instruction::BitCast &&
1461-
CE2->getType()->isVectorTy() == CE2Op0->getType()->isVectorTy() &&
1462-
!CE2Op0->getType()->isFPOrFPVectorTy()) {
1463-
Constant *Inverse = ConstantExpr::getBitCast(C1, CE2Op0->getType());
1464-
return ConstantExpr::getICmp(Predicate, Inverse, CE2Op0);
1465-
}
1466-
}
1467-
14681454
if ((!isa<ConstantExpr>(C1) && isa<ConstantExpr>(C2)) ||
14691455
(C1->isNullValue() && !C2->isNullValue())) {
14701456
// If C2 is a constant expr and C1 isn't, flip them around and fold the

0 commit comments

Comments
 (0)