[llvm] [GlobalISel] Fold G_ICMP if possible (PR #86357)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 07:29:16 PDT 2024


shiltian wrote:

@aemerson @arsenm 
I think we should really avoid using a defined register as destination operand for another new instruction. This basically breaks the SSA rule. If there is no constant folding when building a new instruction between the two same definitions, it doesn't have any issue so far. People will be likely to run into a similar issue as here in the future if they want to add new constant folding. In the combiner, most of the functions define a new vreg for the destination, and then replace the original one with the new one. The replacement, depending on the original register, could be a `G_COPY`, like what we are doing here. In fact, the build of COPY kind of also breaks the SSA rule because it uses a defined register as destination. I think that should be the only exception, and there should not be any other kind of new instructions built between this point and the erase of the original instruction. Interestingly, it may not always work if we erase the original instruction first and then build others because the builder will complain that the insert point is out of the basic block.

https://github.com/llvm/llvm-project/pull/86357


More information about the llvm-commits mailing list