static unsigned long long r; void Test(unsigned long a, unsigned long b, unsigned long long c){ /* Failed with: r = ( (( a ^ b ) & c) ) ; */ r = ( (( (unsigned long long)a ^ (unsigned long long)b ) & c) ) ; return; } main(){ Test(1,2,3); if(r == 3){printf("PASSED\n"); return 0;}else{printf("FAILED\n");return 1;} }
Does this work with -fno-delayed-branch? I do not know the rules on sparc for delay slots of branch instructions so if it works with that then that is the problem because looking to at the asm looks right except for the store after the return.
Subject: AW: [SPARC] -O1: wrong code for expr. wi th cast to long long and exclusive or No it fails with -01 -fno-delayed-branch too. This is my assembler file for -O1 -S (code for the expression ( (( (unsigned long long)a ^ (unsigned long long)b ) & c) ) is not in function Test. -fno-delayed-branch does not change function Test): .file "x.c" .section ".text" .align 4 .global Test .type Test, #function .proc 020 Test: !#PROLOGUE# 0 !#PROLOGUE# 1 mov 0, %o4 mov 0, %o5 sethi %hi(r), %g1 retl std %o4, [%g1+%lo(r)] .size Test, .-Test .section ".rodata" .align 8 .LLC1: .asciz "FAILED" .align 8 .LLC0: .asciz "PASSED" .section ".text" .align 4 .global main .type main, #function .proc 04 main: !#PROLOGUE# 0 save %sp, -112, %sp !#PROLOGUE# 1 mov 1, %o0 mov 2, %o1 mov 0, %o2 call Test, 0 mov 3, %o3 sethi %hi(r), %g1 or %g1, %lo(r), %o5 ld [%g1+%lo(r)], %g1 cmp %g1, 0 bne .LL5 sethi %hi(.LLC1), %o0 ld [%o5+4], %g1 cmp %g1, 3 bne .LL5 nop sethi %hi(.LLC0), %o0 call puts, 0 or %o0, %lo(.LLC0), %o0 b .LL2 mov 0, %i0 .LL5: call puts, 0 or %o0, %lo(.LLC1), %o0 mov 1, %i0 .LL2: nop ret restore .size main, .-main .local r .common r,8,8 .ident "GCC: (GNU) 3.3" -----Ursprüngliche Nachricht----- Von: pinskia at physics dot uc dot edu [mailto:gcc-bugzilla@gcc.gnu.org] Gesendet: Donnerstag, 24. Juli 2003 17:21 An: Brand, Heinrich Betreff: [Bug optimization/11662] [SPARC] -O1: wrong code for expr. with cast to long long and exclusive or PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11662 pinskia at physics dot uc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Summary|[SPARC] -O1: wrong code for |[SPARC] -O1: wrong code for |expr. with cast to long long|expr. with cast to long long |and exclusive or |and exclusive or ------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-24 15:20 ------- Does this work with -fno-delayed-branch? I do not know the rules on sparc for delay slots of branch instructions so if it works with that then that is the problem because looking to at the asm looks right except for the store after the return. ------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter. -----Ursprüngliche Nachricht----- Von: pinskia at physics dot uc dot edu [mailto:gcc-bugzilla@gcc.gnu.org] Gesendet: Donnerstag, 24. Juli 2003 17:21 An: Brand, Heinrich Betreff: [Bug optimization/11662] [SPARC] -O1: wrong code for expr. with cast to long long and exclusive or PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11662 pinskia at physics dot uc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Summary|[SPARC] -O1: wrong code for |[SPARC] -O1: wrong code for |expr. with cast to long long|expr. with cast to long long |and exclusive or |and exclusive or ------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-24 15:20 ------- Does this work with -fno-delayed-branch? I do not know the rules on sparc for delay slots of branch instructions so if it works with that then that is the problem because looking to at the asm looks right except for the store after the return. ------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
Thanks for the asm, this looks like it is fixed on the mainline (20030714 at least with a cross- compiler from powerpc-apple-darwin6.6): !#PROLOGUE# 0 !#PROLOGUE# 1 xor %o0, %o1, %o0 mov %o0, %o1 mov 0, %o0 and %o0, %o2, %o0 and %o1, %o3, %o1 sethi %hi(r.0), %g1 retl std %o0, [%g1+%lo(r.0)] I do not have a cross-compiler to check on 3.3.1 prelease though.
I can confirm this in 3.3.1 (20030714) so this is bad, I am testing 3.2.3 to see if this is a regression.
3.2.3 also had the same problem
It worked in 3.0.4 so this is a regression.
Subject: AW: [3.3 regression][SPARC] -O1: wrong c ode for expr. with cast to long long and exclusive or Hint: Compiled with "-01 -da" xor (one of the missing operations) is in .life but not in .combine -----Ursprüngliche Nachricht----- Von: pinskia at physics dot uc dot edu [mailto:gcc-bugzilla@gcc.gnu.org] Gesendet: Donnerstag, 24. Juli 2003 23:00 An: Brand, Heinrich Betreff: [Bug optimization/11662] [3.3 regression][SPARC] -O1: wrong code for expr. with cast to long long and exclusive or PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11662 pinskia at physics dot uc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |critical Priority|P2 |P1 Summary|[3.3 only][SPARC] -O1: wrong|[3.3 regression][SPARC] -O1: |code for expr. with cast to |wrong code for expr. with |long long and exclusive or |cast to long long and | |exclusive or ------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-24 20:59 ------- It worked in 3.0.4 so this is a regression. ------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
This is a combine bug where CLOBBER expressions, that are meant to make the combine attempt fail are folded and treated as zero. It got fixed in 3.4 by this hunk: 2003-07-10 Denis Chertykov <denisc@overta.ru> Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * combine.c (gen_binary): Handle the CLOBBER rtx and don't build a binary operation with it. I'll add the relevant backported hunk as a proposed patch. But it'll take some time to get it bootstrapped and regresison tested. regards Christian
Created attachment 4479 [details] Proposed patch backported from 3.4
The testsuite (c,c++) completed. There were these two unexpected failures. Neither of these seems to be new: FAIL: gcc.dg/duff-2.c (test for excess errors) FAIL: g++.other/decl5.C caused compiler crash As this is a regression, a wrong code generation bug and a patch is availiable I retarget this for 3.3.1. Not sure if it is too late or not.
Those two failures are unrelated to the patch as g++.other/decl5.C efects i686 also and gcc.dg/duff-2.c effects powerpc also.
Postponed until GCC 3.3.2.
*** Bug 11181 has been marked as a duplicate of this bug. ***
Christian's patch looks good. I'm going to retest it and resubmit it for inclusion in GCC 3.3.2.
Subject: Bug 11662 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: ebotcazou@gcc.gnu.org 2003-09-07 09:59:14 Modified files: gcc : ChangeLog combine.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.c-torture/execute: 20030907-1.c Log message: PR optimization/11662 Backport from mainline: 2003-07-10 Denis Chertykov <denisc@overta.ru> Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * combine.c (gen_binary): Handle the CLOBBER rtx and don't build a binary operation with it. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.726&r2=1.16114.2.727 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.325.2.9&r2=1.325.2.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.268&r2=1.2261.2.269 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030907-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00400.html