Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #307

Re: How to eliminate redundant constant move instructions

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.compilers
Subject Re: How to eliminate redundant constant move instructions
Date 2011-11-01 22:35 +0000
Organization Aioe.org NNTP Server
Message-ID <11-11-005@comp.compilers> (permalink)
References <11-10-019@comp.compilers> <11-11-004@comp.compilers>

Show all headers | View raw


George Neuner <gneuner2@comcast.net> wrote:

(big snip on optimization and register loads)

> You might be asking "if the value already is in a register, why not
> just use it rather than load a second register?"  The answer to that
> likely is a scheduling issue which depends on the use of the first
> register.  You have to remember that many CPUs can execute multiple
> instructions in parallel, and those parallel instruction streams may
> be executed out of order with respect to a program listing.

That is what register renaming is for.  Usually using more than
the architecturally specified number of registers, the CPU
internally remaps the registers such that it can keep one value
in a register while an instruction is being executed out of order.

This is especially important for IA32, with so few registers,
and for S/360 and S/370 floating point, again with few registers.
(Sometime in ESA/390 it was increased to 16, as the instruction
bits were there.)

> On most CPUs loading an immediate constant is as cheap as a register
> move.  Also, loading a constant ties up only the target register
> whereas a move ties up both target and source registers.

Dynamic programming with the appropriate weights should choose
the optimal instruction sequence.  If register clear is faster
than load immediate it would be chosen.  Now, how to choose the
weights when one doesn't know the specific target processor?
That is a good question.

> So a lot more information is needed to say whether the compiler is
> doing something dumb or doing something clever.

-- glen

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How to eliminate redundant constant move instructions "Amker.Cheng" <amker.cheng@gmail.com> - 2011-10-31 17:53 +0800
  Re: How to eliminate redundant constant move instructions Kaz Kylheku <kaz@kylheku.com> - 2011-10-31 17:08 +0000
    Re: How to eliminate redundant constant move instructions amker <can.finner@gmail.com> - 2011-11-01 19:01 -0700
    Re: How to eliminate redundant constant move instructions mac <acolvin@efunct.com> - 2011-11-03 02:20 +0000
  Re: How to eliminate redundant constant move instructions George Neuner <gneuner2@comcast.net> - 2011-11-01 14:32 -0400
    Re: How to eliminate redundant constant move instructions glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-11-01 22:35 +0000
      Re: How to eliminate redundant constant move instructions amker <can.finner@gmail.com> - 2011-11-01 19:35 -0700
      Re: How to eliminate redundant constant move instructions amker <amker.cheng@gmail.com> - 2011-11-01 21:04 -0700
      Re: How to eliminate redundant constant move instructions George Neuner <gneuner2@comcast.net> - 2011-11-02 12:38 -0400
        Re: How to eliminate redundant constant move instructions Kaz Kylheku <kaz@kylheku.com> - 2011-11-03 03:20 +0000
          Re: How to eliminate redundant constant move instructions George Neuner <gneuner2@comcast.net> - 2011-11-04 13:27 -0400
            Re: How to eliminate redundant constant move instructions glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-11-04 21:19 +0000
        Re: How to eliminate redundant constant move instructions glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-11-03 03:32 +0000
    Re: How to eliminate redundant constant move instructions amker <can.finner@gmail.com> - 2011-11-01 19:21 -0700
      Re: How to eliminate redundant constant move instructions George Neuner <gneuner2@comcast.net> - 2011-11-04 17:26 -0400
        Re: How to eliminate redundant constant move instructions amker <amker.cheng@gmail.com> - 2011-11-07 17:33 -0800
          Re: How to eliminate redundant constant move instructions Wei-Jen Chen <chenwj@cs.NCTU.edu.tw> - 2011-11-10 08:04 +0000
          Re: How to eliminate redundant constant move instructions George Neuner <gneuner2@comcast.net> - 2011-11-10 18:18 -0500
    Re: How to eliminate redundant constant move instructions amker <amker.cheng@gmail.com> - 2011-11-01 20:58 -0700

csiph-web