Flag for global variable DSE (dead store elimination)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Flag for global variable DSE (dead store elimination)

I was wondering if it's possible to optimize the code below. My program doesn't depend on global variables unless it uses an atomic load/store/swap
Essentially, I'd like the store to be moved into the if statement. The first function is my test function, the second is what I would like the optimizer to do

https://godbolt.org/z/468crvqe3

int myglobal;

void something1(void);
void something2(void);

int myfunc(int v) {
    something1();
    int g = myglobal;
    myglobal = 456;
    if (v == 123) {
        something2();
    }
    myglobal = g;
}
int expectingImpl(int v) {
    something1();
    if (v == 123) {
        int g = myglobal;
        myglobal = 456;
        something2();
        myglobal = g;
    }
}






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux