RFC: PATCH: Add -m8bit-idiv for x86

Uros Bizjak ubizjak@gmail.com
Thu Sep 16 00:40:00 GMT 2010


On Thu, Sep 16, 2010 at 12:37 AM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>>>>>> This patch generates 2 idivbs since the optimization is done at RTL
>>>>>>> expansion. Is there a way to delay this until later when 2 idivls are
>>>>>>> optimized into 1 idivl and before IRA since this optimization needs
>>>>>>> a scratch register.
>>>>>>
>>>>>> Splitter with && can_create_pseudo_p () split constraint will limit
>>>>>> splits to pre-regalloc passes, or ...
>>>>>
>>>>> try_split doesn't allow any insn of the result matches the original pattern
>>>>> to avoid infinite loop.
>>>>
>>>> So, switch the places of div and mod RTXes in the parallel and provide
>>>> another divl_1 insn pattern that matches this new parallel.
>>>>
>>>
>>> Here is the updated patch.  I added 2 splitters for each divmod pattern.
>>> It splits 32bit divmod into
>>>
>>> if (dividend and divisor are in [0-255])
>>>  use 8bit unsigned integer divide
>>> else
>>>  use 32bit integer divide
>>>
>>> before IRA. It works quite well.  OK for trunk if there are no regressions
>>> on Linux./ia32 and Linux/x86-64?

Some comments on new code below...

> +extern void ix86_split_idivmod (bool, enum machine_mode, rtx[]);

Can you please add bool as the last argument (this is the way all
other functions are defined).

> +;; Math-dependant single word integer modes without QImode and HImode.
> +(define_mode_iterator SWIM48 [SI (DI "TARGET_64BIT")])

This is the same as SWI48, please use SWI48 instead (SI and DI modes
are not dependant on TARGET_{QI,HI}MODE_MATH).

> +(define_expand "testdi_ccno_1"
> +  [(set (reg:CCNO FLAGS_REG)
> +	(compare:CCNO
> +	  (and:DI (match_operand:DI 0 "nonimmediate_operand" "")
> +		  (match_operand:DI 1 "nonmemory_operand" ""))
> +	  (const_int 0)))]
> +  "TARGET_64BIT"
> +  "")

Uh, no. There is no DImode immediate operand. You should use
"x86_64_szext_general_operand" predicate with "&& !(MEM_P
(operands[0]) && MEM_P (operands[1]))" insn predicate, to match
*testdi_1 insn.

OK with these changes, but please wait a day or two for eventual
comments from other people involved in this discussion.

Thanks,
Uros.



More information about the Gcc-patches mailing list