summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-05-17 15:34:31 +0200
committerNikita Popov <npopov@redhat.com>2023-05-17 15:51:09 +0200
commit3d53587901105ee6a4330d9fe8081adbe5e46f55 (patch)
tree301f4378dda961908c708d24c97f6607187cada9
parent86221a1281cf640814daa928fbfc15f6e45a0bed (diff)
downloadllvm-3d53587901105ee6a4330d9fe8081adbe5e46f55.tar.gz
[InstCombine] Don't create bitcast when simplifying round-trip
The bitcast was not being added to the worklist. I could switch this to use the IRBuilder instead, but this bitcast is not relevant with opaque pointers anyway, so just drop it entirely.
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp8
-rw-r--r--llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll2
2 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 5adbb8f66ee8..41cbcb11c1db 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -361,7 +361,7 @@ static bool simplifyAssocCastAssoc(BinaryOperator *BinOp1,
return true;
}
-// Simplifies IntToPtr/PtrToInt RoundTrip Cast To BitCast.
+// Simplifies IntToPtr/PtrToInt RoundTrip Cast.
// inttoptr ( ptrtoint (x) ) --> x
Value *InstCombinerImpl::simplifyIntToPtrRoundTripCast(Value *Val) {
auto *IntToPtr = dyn_cast<IntToPtrInst>(Val);
@@ -373,10 +373,8 @@ Value *InstCombinerImpl::simplifyIntToPtrRoundTripCast(Value *Val) {
CastTy->getPointerAddressSpace() ==
PtrToInt->getSrcTy()->getPointerAddressSpace() &&
DL.getTypeSizeInBits(PtrToInt->getSrcTy()) ==
- DL.getTypeSizeInBits(PtrToInt->getDestTy())) {
- return CastInst::CreateBitOrPointerCast(PtrToInt->getOperand(0), CastTy,
- "", PtrToInt);
- }
+ DL.getTypeSizeInBits(PtrToInt->getDestTy()))
+ return PtrToInt->getOperand(0);
}
return nullptr;
}
diff --git a/llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll b/llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
index 5249aa4269e8..f23caaed9bcb 100644
--- a/llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
+++ b/llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -passes=instcombine -S -disable-i2p-p2i-opt < %s | FileCheck %s
+; RUN: opt -passes=instcombine -instcombine-infinite-loop-threshold=2 -S -disable-i2p-p2i-opt < %s | FileCheck %s
target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64"
target triple = "x86_64-unknown-linux-gnu"