[PATCH] D111777: [GlobalISel] Refactor CSEMIRBuilder's handling of unary op constant folding. NFC.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 18 14:29:59 PDT 2021


aemerson added a comment.

In D111777#3071406 <https://reviews.llvm.org/D111777#3071406>, @arsenm wrote:

> In D111777#3066274 <https://reviews.llvm.org/D111777#3066274>, @foad wrote:
>
>> No particular objection from me, though it would be more consistent if ConstantFoldUnaryOp built the G_CONSTANT, just like ConstantFoldVectorUnaryOp builds the G_BUILD_VECTOR.
>>
>> That then raises the question of how you would call these functions from CombinerHelper match* functions, which don't want to build the IR until you get to the corresponding apply* function.
>>
>> That then also raises the question of whether we really want to be doing constant folding both in the builder and in combiners.
>
> I think the answer is yes, but for different reasons. I think constant folding in the builder only makes sense for handful of artifact-like operations, but general constant folding is always going to be needed in the combiners as other operations fold to constants

I agree, but I think there's also the case where the MIRBuilder may be being used at a point in the pipeline where another combine phase isn't coming to save the day. There could be value in having the builder be proactive about not leaving behind constant-foldable instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111777



More information about the llvm-commits mailing list