Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

C for Loop

$
0
0

Hi everyone,

I am writing a program in C and I have a for loop 0 to N where N can take one of 3 values (1000, 2000 and 4000) all via user input. Is there any way to let the compiler know so that it can make some of the loop specific optimisations? Something like

if(1000==N){*some code*}

else if(2000==N){*something else} ...

could work but I am concerned about final code size and branching time. A switch might be faster but there is still a lot of duplicate code. What can I do?

Thanks!


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>