[llvm] [InstCombine][AMDGPU] Disable PtrReplacer when select has mismatch AS. (PR #98456)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 10:38:14 PDT 2024
================
@@ -270,16 +270,54 @@ class PointerReplacer {
unsigned ToAS = ASC->getDestAddressSpace();
return (FromAS == ToAS) || IC.isValidAddrSpaceCast(FromAS, ToAS);
}
+ bool FoundASC(const Value *TrueOp) const;
+ bool hasConflictingAS(const Instruction *I) const;
SmallPtrSet<Instruction *, 32> ValuesToRevisit;
+ SmallPtrSet<Instruction *, 32> ValuesToRevisitAS;
SmallSetVector<Instruction *, 4> Worklist;
MapVector<Value *, Value *> WorkMap;
InstCombinerImpl &IC;
Instruction &Root;
unsigned FromAS;
+ bool HasASC = false;
};
} // end anonymous namespace
+/// Return true iff valid addrspacecast is found on
+/// path from end of branch to root of tree.
+bool PointerReplacer::FoundASC(const Value *Op) const {
+ const Instruction *TI;
+ while ((TI = dyn_cast<Instruction>(Op)) != &Root) {
+ if (auto *ASC = dyn_cast<AddrSpaceCastInst>(Op))
+ if (isEqualOrValidAddrSpaceCast(ASC, FromAS))
+ return true;
+ if (TI && isa<Instruction>(TI->getOperand(0)))
+ Op = TI->getOperand(0);
+ else if (TI)
+ Op = TI->getOperand(1);
+ else
+ break;
+ }
+ return false;
+}
+
+/// Return true iff valid ASCs are found on both true and false
+/// paths from the select to the root alloca.
+bool PointerReplacer::hasConflictingAS(const Instruction *I) const {
----------------
shiltian wrote:
I'd make it `const SelectInst *SI`.
https://github.com/llvm/llvm-project/pull/98456
More information about the llvm-commits
mailing list