https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125765

Milan Tripkovic <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #64919|0                           |1
        is obsolete|                            |

--- Comment #5 from Milan Tripkovic <[email protected]> ---
Created attachment 65052
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65052&action=edit
my new version of patch

I have uploaded a new patch that modifies noce_try_store_flag_constants
to handle our scenario. However, it currently only applies to the first
example and rejects the second one due to costing issue.

So basically, I introduced a bool defaultcase, initially set to true.
If all existing cases fail to match, but our case got matched,
set it to false. This flag is then used to bypass the standard
start_sequence block and emit our start_sequence block.

ASM for 1st example:

        li      a5,-16
        czero.nez       a0,a5,a2
        li      a5,65536
        addi    a5,a5,-240
        add     a0,a0,a5
        ret

In the 2nd example my sequence RTL would be:

(insn 25 0 26 (set (reg:DI 141)
        (const_int -12 [0xfffffffffffffff4])) 275 {*movdi_64bit}
     (nil))

(insn 26 25 27 (set (reg:DI 139)
        (if_then_else:DI (ne:DI (reg/v:DI 135 [ a ])
                (const_int 0 [0]))
            (reg:DI 141)
            (const_int 0 [0]))) 44986 {*czero.eqz.didi}
     (nil))
(insn 27 26 28 (set (reg:DI 143)
        (high:DI (symbol_ref/u:DI ("*.LC1") [flags 0x82]))) 275 {*movdi_64bit}
     (nil))

(insn 28 27 29 (set (reg:DI 142)
        (mem/u/c:DI (lo_sum:DI (reg:DI 143)
                (symbol_ref/u:DI ("*.LC1") [flags 0x82])) [0  S8 A64])) 275
{*movdi_64bit}
     (expr_list:REG_EQUAL (const_int 1234567890135 [0x11f71fb04d7])
        (nil)))

(insn 29 28 0 (set (reg:DI 134 [ <retval> ])
        (plus:DI (reg:DI 139)
            (reg:DI 142))) 5 {*adddi3}
     (expr_list:REG_EQUAL (plus:DI (reg:DI 139)
            (const_int 1234567890135 [0x11f71fb04d7]))
        (nil)))

New sequence insn 28 cost=32.
Because of this, new_seqcost=48 while original_cost=24 and
noce_conversion_profitable_p fails and function return false.

Reply via email to