[PATCH] D116327: [Coroutines] Enhance symmetric transfer for constant CmpInst
John McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 21:01:00 PST 2022
rjmccall added inline comments.
================
Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1244
+ return false;
+
+ auto *CondConst = dyn_cast<ConstantInt>(CondCmp->getOperand(1));
----------------
I liked the old comment that was here that explained why we bother handling this case.
================
Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1247
+ if (!CondConst)
+ return false;
+
----------------
Should we do the same lookup in `ResolvedValues` here?
I would suggest having a general helper that you can put at the top of this function:
```
auto tryResolveConstant = [&](Value *V) -> Constant* {
auto it = ResolvedValues.find(V));
if (it != ResolvedValues.end())
V = it->second;
return dyn_cast<Constant>(V);
};
```
You don't need to check specifically for `ConstantInt`; LLVM can constant-fold some conditions on other kinds of constants.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116327/new/
https://reviews.llvm.org/D116327
More information about the llvm-commits
mailing list