[PATCH] D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 09:03:23 PDT 2021


spatel added a comment.

In D102698#2777107 <https://reviews.llvm.org/D102698#2777107>, @vdsered wrote:

>   bool llvm::isOnlyUserOfAnyOperand(Instruction *I) {
>       return llvm::any_of(I->operands(), [](Value *V) { return V->hasOneUser(); })
>   }
>
> This solution would be good too especially because it is easier to understand, but I'd leave it as-is without hasOneUser in case there are no any performance/logical issues with it.

I didn't understand the comment. That implementation definitely looks nicer than what we have in the current patch (nit: no need to explicitly use `llvm::` namespace prefix). Is there a reason not to do that (or the alternate suggestion of changing the caller code only with hasOneUser()? I slightly prefer adding this inspection method because it will make the caller code more obviously different than the usual hasOneUse() code pattern, but either way seems fine to me.


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

https://reviews.llvm.org/D102698



More information about the llvm-commits mailing list