[llvm] [EarlyCSE] Compare GEP instructions based on offset (PR #65875)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 18:04:11 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);
----------------
DianQK wrote:
https://github.com/llvm/llvm-project/pull/65875/files#diff-77f80fb318742b6bfa0825b341fb6e8cf89141fe8200f3574d556aa48db5114fL551-R551
This line breaks git-based incremental formatting.
https://github.com/llvm/llvm-project/pull/65875
More information about the llvm-commits
mailing list