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]

Re: CONST_CALL_P questions



  In message <199908060416.AAA23620@jwlab.FEITH.COM>you write:
  > 1) What's an example declaration and usage of a const call function?
  >    I've been trying unsuccessfully to produce a sample which shows
  >    up in a RTL dump.
I would expect any of the intrinsic math functions to show up with 
CONST_CALL_P -- mulsi3, muldi3, addsi3, adddi3, etc etc.

You should also be able to construct one using an attribute.


  > 2) If the INSN has CONST_CALL_P set then does that mean the call
  >    has no possible side effects (not even in the parameters passed
  >    to the call)?  For example the parameters don't have PRE_DEC register
  >    notes, volatile memory references, etc. and that the function doesn't
  >    write to memory, modify global registers, reference volatile memory,
  >    etc.
This is covered in the manual.  A "const" function is a pure function -- it
evaluates its operands and produces a result based solely on those operands.

It is not supposed to read/write memory (except for its own local stack space),
modify global memory, etc.

It can clobber its input parameters if they are passed in registers.  It's not
clear if it is allowed to clobber them if they are on the stack.

Basically think of a constant call as allowing two calls with identical
operands to be CSE'd since (in theory) the two calls should produce the same
result since they have the same inputs.

jeff


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