This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcse pass: expression hash table


On Wed, 23 Feb 2005, James E Wilson wrote:

Tarun Kawatra wrote:
During expression hash table construction in gcse pass(gcc vercion 3.4.1), expressions like a*b does not get included into the expression hash table. Such expressions occur in PARALLEL along with clobbers.

You didn't mention the target, or exactly what the mult looks like.

Target is i386 and the mult instruction looks like the following in RTL


(insn 22 21 23 1 (parallel [
            (set (reg/v:SI 62 [ c ])
                (mult:SI (reg:SI 66 [ a ])
                    (reg:SI 67 [ b ])))
            (clobber (reg:CC 17 flags))
        ]) 172 {*mulsi3_1} (nil)
    (nil))



However, this isn't hard to answer just by using the source. hash_scan_set calls want_to_cse_p calls can_assign_to_reg_p calls added_clobbers_hard_reg_p which presumably returns true, which prevents the optimization. This makes sense. If the pattern clobbers a hard reg, then we can't safely insert it at any place in the function. It might be clobbering the hard reg at a point where it holds a useful value.

If that is the reason, then even plus expression (shown below) should not be subjected to PRE as it also clobbers a hard register(CC). But it is being subjected to PRE. Multiplication expression while it looks same does not get even in hash table.

(insn 35 34 36 1 (parallel [
            (set (reg/v:SI 74 [ c ])
                (plus:SI (reg:SI 78 [ a ])
                    (reg:SI 79 [ b ])))
            (clobber (reg:CC 17 flags))
        ]) 138 {*addsi_1} (nil)
    (nil))

-tarun

While looking at this, I noticed can_assign_to_reg_p does something silly. It uses "FIRST_PSEUDO_REGISTER * 2" to try to generate a test pseudo register, but this can fail if a target has less than 4 registers, or if the set of virtual registers increases in the future. This should probably be LAST_VIRTUAL_REGISTER + 1 as used in another recent patch.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]