[PATCH] D94861: [InstCombine,InstSimplify] Optimize select followed by and/or/xor
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 16 06:09:57 PST 2021
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3470
+ if (Flag && (!CmpT || CmpT->hasOneUse()) &&
+ (!CmpF || CmpF->hasOneUse())) {
+ if (CmpT)
----------------
I find the conditions here hard to understand. Can we write it like this?
```
bool InvertibleT = (CmpT && CmptT->hasOneUse()) || isa<ConstantInt>(TV);
bool InvertibleF = (CmpF && CmptF->hasOneUse()) || isa<ConstantInt>(FV);
if (InvertibleT && InvertibleF)
```
This does not explicitly exclude the `? true : false` case, but that shouldn't be a problem.
Though checking for `isa<Constant>` here means that this transform will not work for vectors I think. It would be good to add a test for that and use a more general predicate.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94861/new/
https://reviews.llvm.org/D94861
More information about the llvm-commits
mailing list