- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please provide us a complete test case, compiler version and compiler options to investigate.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since we have not heard from you, we assume that this is no longer an issue. Thus, we will no longer respond to this thread.
If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RE:
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);
}
};
In the specific case above, even the MS compiler did not fully optimize the code above. That specific function (and return static const RetVals list) could have been reduced to return(Arg & 3).
FWIW your source statement switch(Arg &= 3) should not have had the "=".
Your code .png for the MS example did not show the dispatch table referenced by
jmp [00401020+ecx*4]
The execution of the MS code would have required a memory fetch from the dispatch table which is not in the instruction pipeline.
In a case of arbitrary values in RetVals, your source code should have been written as
return(RetVals[Arg&3]);
IOW, you should work with your compiler as opposed to relying on the compiler to correct your inefficiencies.
For this example, both compilers did poorly.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page