[llvm] [EarlyCSE] Compare GEP instructions based on offset (PR #65875)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 06:14:56 PDT 2023
================
@@ -553,6 +553,77 @@ bool DenseMapInfo<CallValue>::isEqual(CallValue LHS, CallValue RHS) {
return LHSI->isIdenticalTo(RHSI);
}
+//===----------------------------------------------------------------------===//
+// GEPValue
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+struct GEPValue {
+ Instruction *Inst;
+ APInt ConstantOffset;
+ bool HasConstantOffset;
+
+ GEPValue(Instruction *I) : Inst(I), HasConstantOffset(false) {
+ assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
+ }
+ GEPValue(Instruction *I, APInt ConstantOffset, bool HasConstantOffset)
+ : Inst(I), ConstantOffset(ConstantOffset),
+ HasConstantOffset(HasConstantOffset) {
+ assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
+ }
+
+ bool isSentinel() const {
+ return Inst == DenseMapInfo<Instruction *>::getEmptyKey() ||
+ Inst == DenseMapInfo<Instruction *>::getTombstoneKey();
+ }
+
+ static bool canHandle(Instruction *Inst) {
+ return isa<GetElementPtrInst>(Inst);
----------------
nikic wrote:
The indents in these functions look wrong -- clang-format?
https://github.com/llvm/llvm-project/pull/65875
More information about the llvm-commits
mailing list