Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
90 Views

Switch-Case Optimization

I try to use ICC, which is positioned as optimizing, and wrote simplest test code for comparison with MS compiler. int __fastcall TestFunc(int Arg) { static const int RetVals[] = { 0,1,2,3 }; switch (Arg &= 3) { case 0: return RetVals[0]; case 1: return RetVals[1]; case 2: return RetVals[2]; case 3: return RetVals[3]; default: __assume(0); } }; Disassembler output of this sample compiled by MS compiler: http://a.radikal.ru/a17/2010/a7/4707764b260b.png Disassembler output of this sample compiled by Intel compiler: http://c.radikal.ru/c24/2010/28/08812a62def0.png o_O I don't understand where are announced perfect optimization?
0 Kudos
1 Reply
Highlighted
Moderator
57 Views

Hi,

Thanks for reaching out to us!

Could you please provide detail of the compiler and its version which you are referring to?

Also, provide the commands, compiler flags you used along with steps to reproduce.

Since your comparing optimizations at the assembly level, we are forwarding this case to Subject Matter Experts.


Thanks & Regards

Goutham


0 Kudos