Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

Optimizing code for II/e vs II/f

Altera_Forum
Honored Contributor II
1,251 Views

Hi, 

 

I noticed when I compiled for II/e that it's putting a bunch of multiply instructions in the assembler, where I would not normally want them. Example: Subtracting two pointer ended up using a multiply. Obviously, I want not multiplies generated in the assembler for II/e. 

 

Does the compiler not receive a hint as to whether it's compiling for II/e vs II/f? Can I tell to that I want to compile for II/e? Can I tell it not to use multiplies? 

 

I know they're basically using GCC, which has a -b and -m option, but I'm not sure they're supported for the Nios II cross-compiled tools. 

 

Thanks, Peter
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
344 Views

Subtracting 2 pointers is more likely to lead to a divide than a multiply! 

Adding an integral value to a pointer is likely to generate a multiply. 

If the compiler doesn't generate a multiply, it can only generate a shift instead, and fast shifts require the 'mul' instruction. 

Certainly a sequence of shifts and adds (which would likely be faster than a multiply on a system with hardware shift but not multiply) is likely to always be slower on a Nios2. 

Try -fno-hw-mul
0 Kudos
Reply