This is the mail archive of the gcc-patches@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] |
| Other format: | [Raw text] | |
On Fri, Aug 10, 2012 at 7:27 AM, Gopalasubramanian, Ganesh
<Ganesh.Gopalasubramanian@amd.com> wrote:
>> -mxop implies -mfma4, but reverse is not true.
>
> I think this handling went in for bdver1.
> But, with bdver2, we have both fma and fma4.
> So for bdver2, -mxop should not be enabling one of them.
>
>> if someone set -mfma4 together
>> with -mfma on the command line, we should NOT disable selected ISA
>> behind user's back
>
> If both -mfma4 and -mfma are enabled, GCC outputs fma4 instructions.
> This, I think is because fma4 instruction patterns are read before fma
> instruction patterns from the ".md" files.
Actually, this is the problem you are trying to solve. The fma4
patterns are defined before fma3, so gcc prefers these.
> So, enabling both -mfma4 and -mfma is not good for bdver2.
You can enable both, in fact - both should be enabled, since you have
various FMA4 intrinsics defined.
> Moreover, if user tries to use, -mfma -mno-fma4 -mxop, the order in which these
> options are used becomes crucial. -mxop enables -mfma4 and by instruction
> patterns fma4 instructions gets listed in the assembly file.
>
> For the below test,
>
> double a,b,c,d;
> int fn(){
> a = b + c * d ;
> return a;
> }
>
> #1) Using options "-O2 -mno-fma4 -mfma -mxop" outputs fma4.
> (vfmaddsd b(%rip), %xmm2, %xmm1, %xmm0)
> #2) Using options "-O2 -mfma -mno-fma4 -mxop" outputs fma4.
> (vfmaddsd b(%rip), %xmm2, %xmm1, %xmm0)
> #3) Using options "-mxop -mno-fma4 -mfma" outpts fma.
> (vfmadd132sd d(%rip), %xmm1, %xmm0)
Attached patch solves this problem by rearranging sse.md patterns to
match preferred order. So, for all your cases, fma3 instructions are
now output, while we still support FMA3 and FMA4 intrinsics.
2012-08-10 Uros Bizjak <ubizjak@gmail.com>
* config/i386/sse.md (*fma_fmadd_<mode>, *fma_fmsub_<mode>,
*fma_fnmadd_<mode>, *fma_fnmsub_<mode>, *fma_fmaddsub_<mode>,
*fma_fmsubadd_<mode>): Move FMA3 insn patterns before FMA4 patterns.
Testing on x86_64-pc-linux-gnu {,-m32} in progress. Patch will be
committed to mainline SVN.
BTW: Since this patch only rearranges the patterns, it is also safe
for 4.7. A follow-up patch will merge patterns using enabled
attribute.
Uros.
Attachment:
p.diff.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |