Improve i386 add

Jan Hubicka jh@suse.cz
Wed Mar 26 22:16:00 GMT 2003


> On Wed, Mar 26, 2003 at 11:26:53AM +0100, Jan Hubicka wrote:
> > > On Tue, Mar 25, 2003 at 11:37:17PM +0100, Jan Hubicka wrote:
> > > > 	* i386.md: New splitters to canonicalize order of arguments for AND.
> > > 
> > > I think this is a mistake.  The bug is elsewhere.
> > 
> > Who should do that?
> 
> No one should "canonicalize" it further.  It's exactly as canonical
> as it needs to be.  If the lea splitter does the wrong thing (I can't
> tell; you didn't give a test case) then fix that.

To be precise, the instruction that gets to flow2 is:

(insn:HI 36 68 37 1 (nil) (parallel [
            (set (reg:DI 1 rdx [77])
                (plus:DI (reg:DI 4 rsi [62])
                    (reg:DI 1 rdx [78])))
            (clobber (reg:CC 17 flags))
        ]) 210 {*adddi_1_rex64} (insn_list 68 (nil))
    (nil))

Our add pattern is accepting this in lea alternative:

(define_insn "*addsi_1"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
	(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
		 (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
   (clobber (reg:CC 17))]
  "ix86_binary_operator_ok (PLUS, SImode, operands)"

That is later split into lea instruction

;; Convert lea to the lea pattern to avoid flags dependency.
(define_split
  [(set (match_operand 0 "register_operand" "")
	(plus (match_operand 1 "register_operand" "")
              (match_operand 2 "nonmemory_operand" "")))
   (clobber (reg:CC 17))]
  "reload_completed
   && true_regnum (operands[0]) != true_regnum (operands[1])"

So the sollution using extra splitter to get the usual "add" form of the
instruction still looks sane.  Doing it with one extra alternative and
one extra condition in regnums looks fine to me too.

The pattern gets produced by my floordf expander that is not quite ready
for mainline yet (and not sure it will be), but there is nothing magic
in the code and normal C equivalent will also exist.
Honza
> 
> 
> r~



More information about the Gcc-patches mailing list