https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119984

            Bug ID: 119984
           Summary: Incorrect code with -O2 and above
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: saul.x.robinson at durham dot ac.uk
  Target Milestone: ---

I have confirmed is bug occurs on 15.1.0 and 12.2.0. Don't know how to find
more recent versions.
Those GCC versions were compiling for a 64bit linux distro.
Also tested and saw the bug on a version of GCC15.1.0 compiled with
--target=sh3eb-elf -disable-nls --without-headers .
I filed it under tree-optimization as I do not know what field to put this
under.

On -O2 and above the second "and" statement seems to not be present in the
machine code.
//==the_Code==
int test_func(long long temp){
        int ci,out;
        ci=temp;
        ci&=0x7f800000;
        ci+=127<<23;
        ci&=0x7f800000;
        out=ci;
        return out;
}
int main(){
        int out=test_func(-1);
        if (out&(1<<31)){return 1;}
        else{return 0;}
}

Reply via email to