Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
50 views

GCC instruction scheduling: how do the algorithms differ?

GCC offers a number of options related to instruction scheduling in the compiler flags. An overview of what this means is on the GCC Wiki for "Instruction Scheduling", but this is well out ...
Greg Kennedy's user avatar
15 votes
1 answer
572 views

NRVO vs early return for types not benefitting from move semantics (GCC 14 -Wnrvo)

GCC 14 introduced a new -Wnrvo flag: New -Wnrvo warning, to warn if the named return value optimization is not performed although it is allowed by [class.copy.elision]. See the manual for more info. ...
Vittorio Romeo's user avatar
0 votes
0 answers
86 views

compiler generated assembler

A question about compiler generated assembler: My to-be-optimized main loop includes two memory accesses instead of register. loop: mov xmm, mem // pre-calculated value pushed on the stack pxor xmm, ...
linuxCowboy's user avatar
0 votes
0 answers
55 views

Optimizing declaration of symbols implemented in stdlib

I'm creating a static compiled application for an embedded device. The device has implementation for common std functions like memset/strlen. In order to reduce the size of the binary I'm compiling ...
Barel13's user avatar
  • 40
1 vote
1 answer
55 views

Unexpected generated infinite loop where there is no side effect [duplicate]

When a program built with gcc 8.4.3 and -O2, following loop was turned into an assembly code of infinite one for(int i=0; i < PCU_MAX; i++) { auto loc = getApp()->Loc[i + 1 + PCU_LOCATION]...
Swift - Friday Pie's user avatar
2 votes
1 answer
98 views

Constant function pointer optimization

I am trying to implement an abstract interface in C using function pointers inside a struct. Something like the following typedef int (*fn_t)(int); typedef struct { int x; const fn_t fnp; }...
user3387106's user avatar
0 votes
0 answers
101 views

GCC: Tell the compiler that access outside array limits is allowed?

We have the following problem: There are often structures that look like this: struct { someType foo; /* The actual length of bar[] depends on the * size passed to malloc() */ ...
Martin Rosenau's user avatar
1 vote
0 answers
65 views

How to force GCC change the generated assembly order of a branch?

My problem is deterministically arranging the position of different branches' code in the compiled binary/assembly. Note that my primary goal is NOT to optimize performance, but to be sure to have a ...
rand0m_scr1pt_k1dd1e's user avatar
0 votes
2 answers
68 views

Program hangs if GCC optimizations are enabled

I'm doing some kind of "homework" on a platform (training.olinfo.it) where, given a certain problem, you have to create a program that solves it, and it must respect memory and time ...
Zaccaria Francescato's user avatar
0 votes
1 answer
95 views

Strange unnecessary stack usage by GCC and Clang [duplicate]

I was using Compiler Explorer and noticed GCC and Clang would emit seemingly unnecessary instructions related to the stack when compiling this simple function (Compiler Explorer). void bar(void); int ...
Locke's user avatar
  • 8,561
8 votes
2 answers
173 views

Why does GCC fail to reduce a loop that increments two locations of the same buffer?

Here is a bounded loop that increments two locations of the same buffer. unsigned int getid(); void foo(unsigned int *counter, unsigned int n) { unsigned int A = getid(); unsigned int ...
AceSrc's user avatar
  • 99
0 votes
1 answer
51 views

Are these codes(concurrent C codes) necessary to use memory barrier?

I found these codes in project libuv 1.3.0. But I can't understand that why memory barriers(for compiler) are need. static int uv__async_make_pending(int* pending) { /* Do a cheap read first. */ ...
Droopy's user avatar
  • 3
0 votes
0 answers
51 views

how to fine tune gcc optimizations for space and speed

I am compiling some embedded software with speed and space constraints, using a pic32 port of gcc. Due to the space constraints, I need to optimize for size (-Os) or the image won't fit (e.g. with -O2)...
user97576's user avatar
0 votes
2 answers
144 views

How to chain avx2 intrinsics efficiently to perform chain of arithmetic operations?

I wrote a large program to simulate molecular system. I ran it on a desktop computer whose processor is a Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz. Most of the time (75%) is used to calculate a Lennard ...
Stef1611's user avatar
  • 2,273
7 votes
0 answers
180 views

Why can the compiler not optimize away the access to this const parameter?

I have already searched for some answers on Google and Stack Overflow, and I am aware that compilers cannot assume that functions won't modify arguments passed through const references, as these ...
Pluto's user avatar
  • 1,032

15 30 50 per page
1
2 3 4 5
56