Compiler optimization involves adapting a compiler to reduce run-time or object size or both. This can be accomplished using compiler arguments (i.e. CFLAGS, LDFLAGS), compiler plugins (DEHYDRA for instance) or direct modifications to the compiler (such as modifying source code).
Questions tagged [compiler-optimization]
3117 questions
2
votes
1 answer
Is it possible to create a pre-compiler plugin for Java 8?
Some background:
I enjoy doing code-golf challenges in Java, where the goal is to do a certain task in as few bytes/characters as possible. As a simply example: checking if an integer n is a prime with an as short as possible (lambda) function is 47…

Kevin Cruijssen
- 9,153
- 9
- 61
- 135
2
votes
1 answer
Compiler design
When code is compiled we use symbol table to store data. Is this symbol table containing data is reused in recompilation or new symbol table is created?

Chirag Tayal
- 459
- 1
- 6
- 14
2
votes
1 answer
Nim compiler optimization flags
Let's say I am compiling my code with nim c -d:release myprog.nim. How can I see what flags are being passed to gcc, and how to specify additional flags? For example I want to use -ffast-math.
I tried to trace the logic in /etc/nim.cfg, but I'd…

Imran
- 12,950
- 8
- 64
- 79
2
votes
1 answer
Visual studio 17 build fails when it is done by PowerShell script
I have following ps script:-
function buildVS
{
param
(
[parameter(Mandatory=$true)]
[String] $path,
[parameter(Mandatory=$false)]
[bool] $nuget = $true,
[parameter(Mandatory=$false)]
[bool]…

masiboo
- 4,537
- 9
- 75
- 136
2
votes
0 answers
Defining minimum cache size for input data with specific frequency and frame rate
Task: My requirement is to find the minimum cache size to process the frame and details are as below:
Please help with calculations:
Consider a camera capturing a 2K resolution video at 30 FPS format is NV12.
Consider the requirement of a…

Harish
- 341
- 1
- 13
2
votes
1 answer
Why can't clang and gcc optimize away this int-to-float conversion?
Consider the following code:
void foo(float* __restrict__ a)
{
int i; float val;
for (i = 0; i < 100; i++) {
val = 2 * i;
a[i] = val;
}
}
void bar(float* __restrict__ a)
{
int i; float val = 0.0;
for (i = 0; i <…

einpoklum
- 118,144
- 57
- 340
- 684
2
votes
2 answers
which version of gcc support the -Ofast optimization level?
I found Ofast level opt in the doc of gcc on http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options.
But when i compile my code using this level,gcc told me not recognize this flag.
I'm using gcc 4.5.2 which is the most recently…

PDF1001
- 173
- 3
- 13
2
votes
0 answers
Performance cost of switching between arm and thumb mode?
Beside latency costs and registers can get reallocated. What are the other source of execution overheads of switching from arm to thumb mode and vice versa during execution that would affect performance?

Matt
- 739
- 2
- 6
- 10
2
votes
3 answers
Unused objects and link time optimization
Let's consider I have a class Permission which is constructed with a username and a permission identifier. The constructor of this permission class will check if the user has that specific permission and throws if not.
Inside the api request…

Gustavo
- 919
- 11
- 34
2
votes
5 answers
What's wrong if compiler optimization is turned on in debug build?
Why is it necessary/recommended to turn off all compiler optimizations when debugging application?
Background
I'm working in an 8-bit micro controller (OKI 411) which has 15K usable code memory space for interrupt service routines + ROM…

Donotalo
- 12,748
- 25
- 83
- 121
2
votes
1 answer
Gcc llvm backend guides to make reading source codes a little bit easier?
I begin to get acquainted with the implementation of algorithms of code-generation and optimizations in gcc and llvm. Can anyone give an advice on where to see materials, articles, lectures about how it arranged in these compilers? I was trying to…
user8922003
2
votes
1 answer
Application callchain incomplete for perf record samples within glibc
I want to get the callchain for my program using the perf tool. But the result is always incomplete, it always lacks the last function which directly invokes usleep. I have tried to record sched:sched_switch, and usleep trace events, but the result…

Wind
- 31
- 2
2
votes
1 answer
g++ Optimization : O2 flag fixes a broken code where O3 breaks it again
This code, for matching a string in NFA, which I think requires O(N^2) memory, predictably breaks when string size is 20,000, then works with -O2 compiled code, then breaks again for -O3. Compilation was done with -std=c++14 enabled. In my opinion,…

Shihab Shahriar Khan
- 4,930
- 1
- 18
- 26
2
votes
1 answer
Why does g++ optimize out a critical section of the following code?
The following code causes a crash in my program, because
void fractalizeSegment() {
// Assume next != NULL
double deltaX = next->x - x;
double deltaY = next->y - y;
// Add 3 new points labeled a1, a2, a3 from this to…

Sven
- 119
- 1
- 8
2
votes
1 answer
Cpp reordering example where timer is not accurate
My understanding is that C++ reorders code when optimizing and simple timers might not provide accurate results for timing execution time. Can someone provide an example where the following code could be reordered?
auto t0 = clock();
auto r =…

lots_of_questions
- 1,109
- 3
- 16
- 24