c/8734: -O2 breaks something in 3.2.1 on x86-64

mcihar@suse.cz mcihar@suse.cz
Thu Nov 28 08:15:00 GMT 2002


>Number:         8734
>Category:       c
>Synopsis:       -O2 breaks something in 3.2.1 on x86-64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 27 09:56:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     mcihar@suse.cz
>Release:        gcc version 3.2.1 20021021 (prerelease) (SuSE Linux)
>Organization:
>Environment:

>Description:
When building python-numeric on x86-64 (http://www.pfdubois.com/numpy/) I get "Internal compiler error", attached test.c is much reduced code where error appears. with -01 it works, with -O2 I get:

test.c: In function `radf3':
test.c:39: unrecognizable insn:
(insn 968 912 26 (set (reg:SI 414)
        (ashift:SI (reg/v:SI 58)
            (const_int 1 [0x1]))) -1 (nil)
    (nil))
test.c:39: Internal compiler error in extract_insn, at recog.c:2158
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.


The test.s file (test.i is for nothing as it is almost the same as test.c):
        .file   "test.c"
        .section        .rodata
        .align 8
        .type   taur.0,@object
        .size   taur.0,8
taur.0:
        .long   0
        .long   3219128320
        .align 8
        .type   taui.1,@object
        .size   taui.1,8
taui.1:
        .long   3898100910
        .long   1072412282
>How-To-Repeat:
try to compile attached test.c with -O2:
gcc -O2 -c test.c -o test.o
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.c"
Content-Disposition: inline; filename="test.c"

#define ref(u,a) u[a]

static void radf3(int ido, int l1, const double cc[], double ch[],
      const double wa1[], const double wa2[])
  {
    static const double taur = -0.5;
    static const double taui = 0.866025403784439;
    int i, k, ic;
    double ci2, di2, di3, cr2, dr2, dr3, ti2, ti3, tr2, tr3;
    for (k=0; k<l1; k++) {
      cr2 = ref(cc,(k + l1)*ido) + ref(cc,(k + 2*l1)*ido);
      ch[3*k*ido] = ref(cc,k*ido) + cr2;
      ch[(3*k+2)*ido] = taui*(ref(cc,(k + l1*2)*ido) - ref(cc,(k + l1)*ido));
      ch[ido-1 + (3*k + 1)*ido] = ref(cc,k*ido) + taur*cr2;
    }
    if (ido == 1) return;
    for (k=0; k<l1; k++) {
      for (i=2; i<ido; i+=2) {
        ic = ido - i;
        dr2 = wa1[i - 2]*ref(cc,i - 1 + (k + l1)*ido) +
            wa1[i - 1]*ref(cc,i + (k + l1)*ido);
        di2 = wa1[i - 2]*ref(cc,i + (k + l1)*ido) - wa1[i - 1]*ref(cc,i - 1 + (k + l1)*ido);
        dr3 = wa2[i - 2]*ref(cc,i - 1 + (k + l1*2)*ido) + wa2[i - 1]*ref(cc,i + (k + l1*2)*ido);
        di3 = wa2[i - 2]*ref(cc,i + (k + l1*2)*ido) - wa2[i - 1]*ref(cc,i - 1 + (k + l1*2)*ido);
        cr2 = dr2 + dr3;
        ci2 = di2 + di3;
        ch[i - 1 + 3*k*ido] = ref(cc,i - 1 + k*ido) + cr2;
        ch[i + 3*k*ido] = ref(cc,i + k*ido) + ci2;
        tr2 = ref(cc,i - 1 + k*ido) + taur*cr2;
        ti2 = ref(cc,i + k*ido) + taur*ci2;
        tr3 = taui*(di2 - di3);
        ti3 = taui*(dr3 - dr2);
        ch[i - 1 + (3*k + 2)*ido] = tr2 + tr3;
        ch[ic - 1 + (3*k + 1)*ido] = tr2 - tr3;
        ch[i + (3*k + 2)*ido] = ti2 + ti3;
        ch[ic + (3*k + 1)*ido] = ti3 - ti2;
      }
    }
  } /* radf3 */



More information about the Gcc-bugs mailing list