[PATCH] D98122: [rs4gc] don't duplicate existing values which are provably base pointers

Denis Antrushin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 02:55:49 PST 2021


dantrushin added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:918
+      if (SelectInst *SI = dyn_cast<SelectInst>(BDV)) {
+        CanPrune &= canPruneInput(SI->getTrueValue());
+        CanPrune &= canPruneInput(SI->getFalseValue());
----------------
skatkov wrote:
> not a fan of &= operation. It will require to execute the function call even if CanPrune is already false.
> Please replace with &&.
I disagree. `&=` is much more concise. Unless its overhead is visible, I'd trade it for readability.
And I'm not sure RHS of `&=` will be evaluated when LHS is false.
```
6.5.16.2 Compound assignment
...
Semantics
3
A compound assignment of the form E1 op = E2 differs from the simple assignment
expression E1 = E1 op (E2) only in that the lvalue E1 is evaluated only once.
```

And for binary operators is can be written as
```
CanPrune = canPrune(0) && canPrune(1)
```
to get rid of that compound assignment at all :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98122/new/

https://reviews.llvm.org/D98122



More information about the llvm-commits mailing list