This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: CONST_CALL_P questions
- To: John Wehle <john@feith.com>
- Subject: Re: CONST_CALL_P questions
- From: Jeffrey A Law <law@cygnus.com>
- Date: Fri, 06 Aug 1999 10:12:30 -0600
- cc: gcc@gcc.gnu.org
- Reply-To: law@cygnus.com
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