User account creation filtered due to spam.

Bug 35346 - Scalar replacement -- handling of conditional generator -- missing
Summary: Scalar replacement -- handling of conditional generator -- missing
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2008-02-24 04:47 UTC by davidxl
Modified: 2008-12-29 06:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-12-29 06:15:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description davidxl 2008-02-24 04:47:07 UTC
// David Li:

Conditional generator is not handled, missing redundancy elimination for a[i] and a[i-1]

int a[1000];
int b[1000];

void foo(int n)
{
   int i = 1;
   for(; i < n; i++)
   {
        if (b[i] > 0)
            a[i+1] = a[i-1];
        b[i] = a[i];
   }
}

==> should be (similar to PRE)

Conditional generator is not handled, missing redundancy elimination for a[i] and a[i-1]

int a[1000];
int b[1000];

t1 = a[0];
t2 = a[1];
void foo(int n)
{
   int i = 1;
   for(; i < n; i++)
   {
        
        if (b[i] > 0)
        {
            t3 = t1;
            a[i+1] = t3;
        }
        else t3 = a[i+1];

        b[i] = t2;
        t1 = t2;
        t2 = t3;
   }
}
(Loop can be unrolled to reduce copy)
Comment 1 Andrew Pinski 2008-04-07 01:37:59 UTC
Confirmed.
Comment 2 Andrew Pinski 2008-12-29 06:15:08 UTC
Hmm:
MEM[symbol: b, index: ivtmp.27, step: 4, offset: 4294967292]

Why do we produce a step and an offset when they cancel?

If we change the store to a[i+1] to be unconditional, predictive commoning does the correct thing.