Removing bound checks from a switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have an event driven simulator that uses a switch statement for executing the next event. Currently, the loop is so tight that removing the bound checks from the switch increased performance by 10%. This I observed halfway in converting from ints to enums for the reactions. However, there were bugs at that point and with these removed the checks were there again (I verified this by looking at the asm).

The code is too big for this post, but I define the reaction type as follows:
enum reaction_T {RDEF=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6};
The program has a const array of the above type to store the dependency graph (that is why I define the values of the enums) and two switch statements that lists all the cases.

The program compiles without warnings on a x86_64: g++ (Ubuntu 4.3.2-1ubuntu12) 4.3.2 with g++ -Wall -Winline -ftree-vectorizer-verbose=0 -pedantic -ansi -O3 -mtune=native -march=native -fno-strict-aliasing -lm -c sim.cc

The program seems to by type safe so the bounds checks should be removed. Is there any way enforce the removal of the bound checks or some compiler switch that could give a hint of what is wrong?

Best regards,
Henrik Mannerström



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux