aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-11-03 12:22:59 +0100
committerNikita Popov <npopov@redhat.com>2023-11-03 12:22:59 +0100
commita7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8 (patch)
tree4f296e16f4e4d7b35064b9b0e0ad7629884dabbb /llvm/lib/IR/ConstantFold.cpp
parentfe206578f2e9b864ec6a703974a0e2a9001bb11b (diff)
downloadllvm-a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8.zip
llvm-a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8.tar.gz
llvm-a7176f8a25fc6930ee7fd0cfcde4d9a96010a5a8.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp14
1 files changed, 0 insertions, 14 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index a10796e..a4df579 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