This is the mail archive of the gcc-bugs@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]

[Bug optimization/14347] New: ifconvert doesn't generate conditional store on i386


x86 doesn't have a conditional store instruction. But it can be simulated.

e.g. in

int foo;

void f(int x) 
{
    if (x == 1) 
       foo = 2;          /* generates a jump */
} 

the jump can be avoided with

void f(int x)
{ 
    int dummy;
    int *fooptr = &dummy;
    if (x == 1) 
        fooptr = &foo;         /* will generate a CMOV and no jump */ 
     *fooptr = 2;
}
       
I think this woule be an useful optimization to have. Right place is probably
ifcvt.c, but it just needs to be somehow taught to generate dummy stack
variables and then recognize this idiom. Also the target may need to set some
flag that it doesn't support conditional stores and they need to be simulated.

It's probably better to generate a new variable for each such optimization to
avoid possible store conflict stalls.

This may help on other architectures with a missing conditional store too.

-- 
           Summary: ifconvert doesn't generate conditional store on i386
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ak at muc dot de
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i386-*, x86_64-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14347


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