Author: Nikita Popov Date: 2023-11-03T12:22:59+01:00 New Revision: a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8
URL: https://github.com/llvm/llvm-project/commit/a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8 DIFF: https://github.com/llvm/llvm-project/commit/a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8.diff LOG: [ConstantFold] Remove handling for icmp of bitcast This only handles the case where the bitcast result is an integer or pointer, and the input is not FP. This means that the input can only be a vector. However, converting a comparison of the whole vector into an element-wise comparison is generally not correct. I assume that this code was originally intended to handle the case where a pointer bitcast is compared to a null pointer, which is no longer relevant with opaque pointers. Given the complete lack of test coverage, and the risk of miscompiles if this code actually did something, I'm opting to remove it entirely. Added: Modified: llvm/lib/IR/ConstantFold.cpp Removed: ################################################################################ diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index a10796e6da99dca..a4df579406538a4 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1243,20 +1243,6 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2, Constant *CE1Op0 = CE1->getOperand(0); switch (CE1->getOpcode()) { - case Instruction::BitCast: - // We can't evaluate floating point casts or truncations. - if (CE1Op0->getType()->isFPOrFPVectorTy()) - break; - - // If the cast is not actually changing bits, and the second operand is a - // null pointer, do the comparison with the pre-casted value. - if (V2->isNullValue() && CE1->getType()->isIntOrPtrTy()) { - return evaluateICmpRelation(CE1Op0, - Constant::getNullValue(CE1Op0->getType()), - isSigned); - } - break; - case Instruction::GetElementPtr: { GEPOperator *CE1GEP = cast<GEPOperator>(CE1); // Ok, since this is a getelementptr, we know that the constant has a _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits