Hi, I think this is a pass-ordering issue: the generic fold already exists, but the expression is exposed after the last generic simplification opportunity. I traced the pass in which the RTL form actually first appears: combine          - does not contain the pattern late_combine1    - does not contain the pattern ce2              - contains it for the first time The first occurrence is:    (set (reg:DI 128)         (if_then_else:DI           (eq:DI (reg/v:DI 82 [c]) (const_int 0))           (reg/v:DI 82 [c])           (const_int 0)))    {*seleqdi_using_di} pass_cse2 makes the condition operand and the true arm the same register through common-subexpression substitution, exposing the expression whose value is always zero.  However, CSE does not re-run simplify_ternary_operation after changing the SET_SRC. late_combine2 later sees the already-formed IF_THEN_ELSE, but late-combine does not simplify an existing SET_SRC. The current split is a local cleanup for the target-specific expansion exposed at this point. Thanks.

在 2026/11/13 06:27, Jeff Law 写道:


On 11/12/26 2:34 PM, Andrea Pinski wrote:
On Thu, Nov 12, 2026 at 1:33 AM Guo Jie <[email protected]> wrote:
RTL can contain:

         (set D (if_then_else:GPR (eq:X OP 0) OP 0))

Both outcomes are zero.  Fold this expression to a move of zero.

gcc/ChangeLog:

         * config/loongarch/loongarch.md: New split.
This should really be done in simplify-rt.cc instead if not already.
Can you check on why it is not?
Yea, 100% agreed.

jeff

Reply via email to