Bug 91036 - GCC option -mno-dspr2 blocks the use of dsp r1 instructions
Summary: GCC option -mno-dspr2 blocks the use of dsp r1 instructions
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-29 17:23 UTC by Petr Cvek
Modified: 2019-07-01 07:10 UTC (History)
0 users

See Also:
Host:
Target: mipsel
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Cvek 2019-06-29 17:23:37 UTC
Setup:

GCC 8.3.0 crosscompiler from aarch64 debian sid to mipsel 24kec with DSP ASE

Simple testing code:

#ifdef __mips_dsp
    #warning "+++ DSP r1"
#endif

#ifdef __mips_dspr2
    #warning "+++ DSP r2"
#endif

#if (__mips_dsp_rev == 1)
    #warning "+++ DSP revision is: 1"
#elif (__mips_dsp_rev == 2)
    #warning "+++ DSP revision is: 2"
#endif

int main(void) {
    asm volatile ("lwx $5,$5($20)\n");
    return 0;
}

Tests:

1) No options (compiler built for arch/tune=24kec and -mdsp):
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c 
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:10:6: warning: #warning "+++ DSP revision is: 1" [-Wcpp]
     #warning "+++ DSP revision is: 1"
      ^~~~~~~

2) With -mdsp option, still OK
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c -mdsp
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:10:6: warning: #warning "+++ DSP revision is: 1" [-Wcpp]
     #warning "+++ DSP revision is: 1"
      ^~~~~~~

3) With -mdspr2 option, works OK, lwx _seems_ to be from DSPr1
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c -mdspr2
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:6:6: warning: #warning "+++ DSP r2" [-Wcpp]
     #warning "+++ DSP r2"
      ^~~~~~~
./no_dspr2_bug.c:12:6: warning: #warning "+++ DSP revision is: 2" [-Wcpp]
     #warning "+++ DSP revision is: 2"
      ^~~~~~~

4) With -mno-dspr2 option, fails as no dsp was defined at all, but still the DSP macros are available
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c -mno-dspr2
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:10:6: warning: #warning "+++ DSP revision is: 1" [-Wcpp]
     #warning "+++ DSP revision is: 1"
      ^~~~~~~
/tmp/cceDi2vp.s: Assembler messages:
/tmp/cceDi2vp.s:24: Error: opcode not supported on this processor: mips32r2 (mips32r2) `lwx $5,$5($20)'

5) Options -mno-dspr2 and -mdsp, IMO useful for situations, when you want only instructions from rev1 subset and not from rev2, fails too:
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c -mno-dspr2 -mdsp
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:10:6: warning: #warning "+++ DSP revision is: 1" [-Wcpp]
     #warning "+++ DSP revision is: 1"
      ^~~~~~~
/tmp/ccNYI1Y8.s: Assembler messages:
/tmp/ccNYI1Y8.s:24: Error: opcode not supported on this processor: mips32r2 (mips32r2) `lwx $5,$5($20)'

6) Behavior for -mdspr2 and -mno-dsp (I don't know what it should do, maybe it should use only new instructions which was added with revision 2?):
# mipsel-unknown-linux-gnu-gcc ./no_dspr2_bug.c -mno-dsp -mdspr2
./no_dspr2_bug.c:2:6: warning: #warning "+++ DSP r1" [-Wcpp]
     #warning "+++ DSP r1"
      ^~~~~~~
./no_dspr2_bug.c:6:6: warning: #warning "+++ DSP r2" [-Wcpp]
     #warning "+++ DSP r2"
      ^~~~~~~
./no_dspr2_bug.c:12:6: warning: #warning "+++ DSP revision is: 2" [-Wcpp]
     #warning "+++ DSP revision is: 2"
      ^~~~~~~