[llvm] [SCCP] Support constant structure in PhiNode (PR #163713)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 17 08:28:03 PDT 2025
================
@@ -2125,6 +2143,21 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
}
}
+bool SCCPInstVisitor::isInstUnderDefined(Instruction &Inst) {
+ // For structure Type, we handle each member seperately.
+ // A structure object won't be considered as overDefined when
+ // there is at least one member can become constant.
+ if (StructType *STy = dyn_cast<StructType>(Inst.getType())) {
+ for (unsigned i = 0, e = STy->getNumElements(); i < e; ++i) {
+ if (!getStructValueState(&Inst, i).isOverdefined())
+ return false;
+ }
+ return true;
----------------
aokblast wrote:
> Not really sure how this is related -- I was just suggesting to write the same loop you currently have in a different way. But looking again, given that this is a counter loop, the result would probably not really be better, so it's fine to just leave it as-is.
I assume that you want me to write something like return all_of(**LatticeVector**, isOverDefined); But when getting **LatticeVector** by **getStructLatticeValueFor**. It panic when one of any member is not presented in the map.
In other word, the original implementation by using getStructValueState(V, I) has a side effect that can insert (V, I) to map when the node does not exist.
https://github.com/llvm/llvm-project/pull/163713
More information about the llvm-commits
mailing list