From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sudish Joseph To: Mark Mitchell Cc: dje@watson.ibm.com, rms@gnu.org, jbuck@synopsys.com, mrs@wrs.com, gcc@gcc.gnu.org Subject: Re: type based aliasing again Date: Sat, 11 Sep 1999 23:40:00 -0000 Message-id: References: <9909120057.AA36240@marc.watson.ibm.com> <19990911182424A.mitchell@codesourcery.com> X-SW-Source: 1999-09/msg00455.html Mark Mitchell writes: > Someone reported something similar for the DEC copmiler; `cc' is > -fno-strict-aliasing, while some more progressive-sounding compiler > name is -fstrict-aliasing. Yes, but more so. :-) DEC cc doesn't enable its -ansi_aliases flag implicitly unless you specify either -std1, thus stating that your code is completely standards compliant, or -fast, thus asking for extremely aggressive optimizations. In particular, -ansi_alias isn't automatically enabled for any `n' in -On. The user must specify -std1, -fast, or -ansi_alias. Here're some more excerpts from the DU 4.0D cc (V5.9-005) man page. (I re-filled the paragraphs to fit, so you'll see some mid-line hyphenation.) -fast also implies -O3 in addition to what's listed below. ------------------------------------------------------------ -std1 Selects the strict ANSI language mode. Strictly enforces the ANSI C standard and all its prohibitions (such as those that apply to the han- dling of void types, the definition of lvalues in expressions, the mix- ing of integrals and pointers, and the modification of rvalues). This option does not restrict the Tru64 UNIX name space (for example, the names defined in system header files). To restrict that name space so that only ANSI C reserved names are visible from the ANSI C header files, use the _ANSI_C_SOURCE macro. See standards(5) for more details. This option causes the macro __STDC_ to be defined to 1. Note that this option also affects linker-defined symbols. See ld(1) for more infor- mation. This option turns on ANSI aliasing rules (-ansi_alias option). [...] -O[n] Determines the level of optimization. The following table lists the types of optimizations that can be performed at each level: --------------------------------------------------------------- Level Optimization --------------------------------------------------------------- -O0 None -O1 Local optimizations and recognition of common subexpressions. Global optimizations, including code motion, strength reduction and test replacement, split lifetime analysis, and code scheduling. -O2, -O Inline expansion of static procedures. Additional global optimizations that improve speed (at the cost of extra code size), such as integer multiplication and division expansion (using shifts), loop unrolling, and code replication to eliminate branches. -O3 Inline expansion of global procedures. -O4 Software pipelining using dependency analysis, vector- ization of some loops on 8-bit and 16-bit data (char and short), and insertion of NOP instructions to improve scheduling. --------------------------------------------------------------- If your application will be built into a shared library, avoid using the -O3 and -O4 options, because these levels may inhibit the ability to preempt symbols. Also, benchmarking is recommended to determine if -O4 is better than -O3 for your particular application, as this is not always true. [...] -fast Provides a single method for turning on a collection of optimizations for increased performance. Note that the -fast option can produce different results for floating- point arithmetic and math functions, although most programs are not sensitive to these differences. The -fast option defines the following compiler options and symbols to improve run-time performance. You can adjust the optimizations by spec- ifying the negation of any given option. -ansi_alias Directs the compiler to assume the ANSI C aliasing rules, and thus allows the optimizer to be more aggressive in its optimizations. See the description of this option elsewhere in this reference page for more detailed information about this operation. -ansi_args Tells the compiler that the source code follows all ANSI rules about arguments; that is, whether the type of an argument matches the type of the parameter in the called function, or whether a function prototype is present so the compiler can automatically perform the expected type conversion. See the description of this option elsewhere in this reference page for more detailed information about this operation. -assume nomath_errno Allows the compiler to reorder or combine computations to improve the performance of those math functions that it recognizes as intrinsic functions. See the description of this option elsewhere in this reference page for more detailed information about this operation. -assume trusted_short_alignment Specifies that any short accessed through a pointer is naturally aligned. This generates the fastest code, but can silently gener- ate the wrong results if any of the short objects cross a quadword boundary. See the description of this option elsewhere in this reference page for more detailed information about this operation. -D_INTRINSICS This option affects the compilation of a number of system header files, causing them to compile #pragma intrinsic directives for certain functions that they declare. The exact functions affected may vary depending on the language mode and other macro defini- tions. See the header files math.h, stdio.h, stdlib.h, string.h, and strings.h for details. The exact effect of each #pragma intrin- sic varies by function, by optimization options, and by other com- pile-time options. The basic effect is to inform the compiler that the function specified in the pragma is the one by that name whose behavior is known to the compiler (that is, it is a standard C or commonly-used library function rather than a user-written external function). This gives the compiler license to perform additional checks on the usage of the function and issue diagnostics, and to optimize and/or rewrite calls to it based on the compiler's under- standing of what the function does. Some possible optimizations include generating complete inline code, generating partial inline code with calls to one or more different functions, or just using characteristics of the function to move the call site or avoid some of the overhead triggered by an external call. -D_INLINE_INTRINSICS This option affects the compilation of stdio.h in two ways: o Whenever the header file would otherwise define getc and putc as preprocessor macros expanding into code to access the _cnt and _ptr members of the referenced FILE object directly, instead these macros are defined to invoke inlined static functions defined in the header file. The use of an inlined static function instead of a simple macro prevents the argu- ment from being evaluated more than once (so arguments con- taining side effects do not cause a problem), and the function generally will produce better code because it uses local dec- larations to avoid aliasing assumptions that the compiler has to make when analyzing the traditional macro expansions of getc and putc. Note that getc and putc are not expanded inline when i/o locking is required, as is normally the case for reentrant or thread-safe compilations. o If -D_INTRINSICS was also specified, making printf and fprintf intrinsic functions, then certain of the low-level runtime support routines that may be called for special cases of for- mat strings are defined as inline static functions in the header file, avoiding external calls to these routines in libc. -D_FASTMATH Causes the /usr/include/math.h file to redefine the names of cer- tain common math routines, including sqrt and exp, so that faster but slightly less accurate functions are used. The fast math rou- tines do not support IEEE exceptional behavior. -float Tells the compiler that it is not necessary to promote expressions of type float to type double. See the description of this option elsewhere in this reference page for more detailed information about this operation. -fp_reorder Allows floating-point operations to be reordered during optimiza- tion. See the description of this option elsewhere in this reference page ------------------------------------------------------------ -- Sudish Joseph MindSpring Enterprises From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sudish Joseph To: Mark Mitchell Cc: dje@watson.ibm.com, rms@gnu.org, jbuck@synopsys.com, mrs@wrs.com, gcc@gcc.gnu.org Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: References: <9909120057.AA36240@marc.watson.ibm.com> <19990911182424A.mitchell@codesourcery.com> X-SW-Source: 1999-09n/msg00455.html Message-ID: <19990930180200.UOG2Zd2-xKcMM5Fxw9cTfCdkM5QYgArLzC5Al4bdvNA@z> Mark Mitchell writes: > Someone reported something similar for the DEC copmiler; `cc' is > -fno-strict-aliasing, while some more progressive-sounding compiler > name is -fstrict-aliasing. Yes, but more so. :-) DEC cc doesn't enable its -ansi_aliases flag implicitly unless you specify either -std1, thus stating that your code is completely standards compliant, or -fast, thus asking for extremely aggressive optimizations. In particular, -ansi_alias isn't automatically enabled for any `n' in -On. The user must specify -std1, -fast, or -ansi_alias. Here're some more excerpts from the DU 4.0D cc (V5.9-005) man page. (I re-filled the paragraphs to fit, so you'll see some mid-line hyphenation.) -fast also implies -O3 in addition to what's listed below. ------------------------------------------------------------ -std1 Selects the strict ANSI language mode. Strictly enforces the ANSI C standard and all its prohibitions (such as those that apply to the han- dling of void types, the definition of lvalues in expressions, the mix- ing of integrals and pointers, and the modification of rvalues). This option does not restrict the Tru64 UNIX name space (for example, the names defined in system header files). To restrict that name space so that only ANSI C reserved names are visible from the ANSI C header files, use the _ANSI_C_SOURCE macro. See standards(5) for more details. This option causes the macro __STDC_ to be defined to 1. Note that this option also affects linker-defined symbols. See ld(1) for more infor- mation. This option turns on ANSI aliasing rules (-ansi_alias option). [...] -O[n] Determines the level of optimization. The following table lists the types of optimizations that can be performed at each level: --------------------------------------------------------------- Level Optimization --------------------------------------------------------------- -O0 None -O1 Local optimizations and recognition of common subexpressions. Global optimizations, including code motion, strength reduction and test replacement, split lifetime analysis, and code scheduling. -O2, -O Inline expansion of static procedures. Additional global optimizations that improve speed (at the cost of extra code size), such as integer multiplication and division expansion (using shifts), loop unrolling, and code replication to eliminate branches. -O3 Inline expansion of global procedures. -O4 Software pipelining using dependency analysis, vector- ization of some loops on 8-bit and 16-bit data (char and short), and insertion of NOP instructions to improve scheduling. --------------------------------------------------------------- If your application will be built into a shared library, avoid using the -O3 and -O4 options, because these levels may inhibit the ability to preempt symbols. Also, benchmarking is recommended to determine if -O4 is better than -O3 for your particular application, as this is not always true. [...] -fast Provides a single method for turning on a collection of optimizations for increased performance. Note that the -fast option can produce different results for floating- point arithmetic and math functions, although most programs are not sensitive to these differences. The -fast option defines the following compiler options and symbols to improve run-time performance. You can adjust the optimizations by spec- ifying the negation of any given option. -ansi_alias Directs the compiler to assume the ANSI C aliasing rules, and thus allows the optimizer to be more aggressive in its optimizations. See the description of this option elsewhere in this reference page for more detailed information about this operation. -ansi_args Tells the compiler that the source code follows all ANSI rules about arguments; that is, whether the type of an argument matches the type of the parameter in the called function, or whether a function prototype is present so the compiler can automatically perform the expected type conversion. See the description of this option elsewhere in this reference page for more detailed information about this operation. -assume nomath_errno Allows the compiler to reorder or combine computations to improve the performance of those math functions that it recognizes as intrinsic functions. See the description of this option elsewhere in this reference page for more detailed information about this operation. -assume trusted_short_alignment Specifies that any short accessed through a pointer is naturally aligned. This generates the fastest code, but can silently gener- ate the wrong results if any of the short objects cross a quadword boundary. See the description of this option elsewhere in this reference page for more detailed information about this operation. -D_INTRINSICS This option affects the compilation of a number of system header files, causing them to compile #pragma intrinsic directives for certain functions that they declare. The exact functions affected may vary depending on the language mode and other macro defini- tions. See the header files math.h, stdio.h, stdlib.h, string.h, and strings.h for details. The exact effect of each #pragma intrin- sic varies by function, by optimization options, and by other com- pile-time options. The basic effect is to inform the compiler that the function specified in the pragma is the one by that name whose behavior is known to the compiler (that is, it is a standard C or commonly-used library function rather than a user-written external function). This gives the compiler license to perform additional checks on the usage of the function and issue diagnostics, and to optimize and/or rewrite calls to it based on the compiler's under- standing of what the function does. Some possible optimizations include generating complete inline code, generating partial inline code with calls to one or more different functions, or just using characteristics of the function to move the call site or avoid some of the overhead triggered by an external call. -D_INLINE_INTRINSICS This option affects the compilation of stdio.h in two ways: o Whenever the header file would otherwise define getc and putc as preprocessor macros expanding into code to access the _cnt and _ptr members of the referenced FILE object directly, instead these macros are defined to invoke inlined static functions defined in the header file. The use of an inlined static function instead of a simple macro prevents the argu- ment from being evaluated more than once (so arguments con- taining side effects do not cause a problem), and the function generally will produce better code because it uses local dec- larations to avoid aliasing assumptions that the compiler has to make when analyzing the traditional macro expansions of getc and putc. Note that getc and putc are not expanded inline when i/o locking is required, as is normally the case for reentrant or thread-safe compilations. o If -D_INTRINSICS was also specified, making printf and fprintf intrinsic functions, then certain of the low-level runtime support routines that may be called for special cases of for- mat strings are defined as inline static functions in the header file, avoiding external calls to these routines in libc. -D_FASTMATH Causes the /usr/include/math.h file to redefine the names of cer- tain common math routines, including sqrt and exp, so that faster but slightly less accurate functions are used. The fast math rou- tines do not support IEEE exceptional behavior. -float Tells the compiler that it is not necessary to promote expressions of type float to type double. See the description of this option elsewhere in this reference page for more detailed information about this operation. -fp_reorder Allows floating-point operations to be reordered during optimiza- tion. See the description of this option elsewhere in this reference page ------------------------------------------------------------ -- Sudish Joseph MindSpring Enterprises