LIKELY __builtin_expect deoptimzes code
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
New
|
Undecided
|
Unassigned |
Bug Description
The following code is compiled on gcc 8.2 using -Os
---
#include <stdint.h>
#ifdef LK
#define LIKELY(x) __builtin_
#else
#define LIKELY(x) (x)
#endif
float a = 66;
int test (float b, int test) {
if(
return b * a;
} else {
return b / a;
}
}
---
Likely should have no effect on the code. However additional instructions are added / are not removed when setting -DLK. (Seems like there is something wrong with the register allocation.)
See https:/
-Os
test:
ldr r3, .L6
cmp r1, #0
ldr r3, [r3] @ float
push {r4, lr}
mov r1, r3
beq .L2
bl __aeabi_fmul
.L5:
bl __aeabi_f2iz
pop {r4, pc}
.L2:
bl __aeabi_fdiv
b .L5
.L6:
.word .LANCHOR0
a:
.word 1115947008
-Os -DLK
test:
ldr r3, .L6
cmp r1, #0
push {r4, lr}
ldr r3, [r3] @ float
beq .L2
mov r1, r0
mov r0, r3
bl __aeabi_fmul
.L5:
bl __aeabi_f2iz
pop {r4, pc}
.L2:
mov r1, r3
bl __aeabi_fdiv
b .L5
.L6:
.word .LANCHOR0
a:
.word 1115947008
Ich bin bis 08.04. nicht im Haus und kann Ihre Nachricht daher leider nicht bearbeiten. In dringenden Fällen wenden Sie sich bitte an <email address hidden> bzw. für technische Fragen an <email address hidden>.
I am out of office until April 8th and won't be able to read your message. In urgent cases, please refer to <email address hidden> or for technical questions to <email address hidden>.
Mit freundlichen Grüßen / Best regards
Steffen Wolfer
--
Dipl.-Inform. Steffen Wolfer
Software Engineer Embedded Systems
WEISS ROBOTICS GmbH & Co. KG Käferle- Str. 8
Karl-Heinrich-
D-71640 Ludwigsburg, Germany
Phone: +49 7141 94702-22 www.weiss- robotics. com
Fax: +49 7141 94702-99
http://
Sitz der Gesellschaft: Ludwigsburg
Registergericht Stuttgart, HRA725006
Pers. haftende Gesellschafterin:
Weiss Robotics Verwaltungs-GmbH, Sitz Ludwigsburg
Registergericht Stuttgart, HRB73310
Geschäftsführer: Dr. Karsten Weiß
Public bug reported:
The following code is compiled on gcc 8.2 using -Os expect( (x),1)
---
#include <stdint.h>
#ifdef LK
#define LIKELY(x) __builtin_
#else
#define LIKELY(x) (x)
#endif
float a = 66;
int test (float b, int test) { LIKELY( test)) {
if(
return b * a;
} else {
return b / a;
}
}
---
Likely should have no effect on the code. However additional instructions are added / are not removed when setting -DLK. (Seems like there is something wrong with the register allocation.)
See https:/ /godbolt. org/z/yVgVC6
-Os
test:
ldr r3, .L6
cmp r1, #0
ldr r3, [r3] @ float
push {r4, lr}
mov r1, r3
beq .L2
bl __aeabi_fmul
.L5:
bl __aeabi_f2iz
pop {r4, pc}
.L2:
bl __aeabi_fdiv
b .L5
.L6:
.word .LANCHOR0
a:
.word 1115947008
-Os -DLK
test:
ldr r3, .L6
cmp r1, #0
push {r4, lr}
ldr r3, [r3] @ float
beq .L2
mov r1, r0
mov r0, r3
bl __aeabi_fmul
.L5:
bl __aeabi_f2iz
pop {r4, pc}
.L2:
mov r1, r3
bl __aeabi_fdiv
b .L5
.L6:
.word .LANCHOR0
a:
.word 1115947008
** Affects: gcc-arm-embedded
Importance: Undecided
Status: New
-- /bugs.launchpad .net/bugs/ 1821703
You received this bug notification because you are subscribed to GNU Arm
Embedded Toolchain.
Matching subscriptions: Älles
https:/
Title:
LIKELY __builtin_expect deoptimzes code
Status in GNU Arm Embedded Toolchain:
New
Bug description: expect( (x),1)
The following code is compiled on gcc 8.2 using -Os
---
#include <stdint.h>
#ifdef LK
#define LIKELY(x) __builtin_
#else
#define LIKELY(x) (x)
#endif
float a = 66;
int test (float b, int test) { LIKELY( test)) {
if(
return b * a;
} else {
return b / a;
}
}
---
Likely should have no effect on the code. However additional instructions are added / are not removed when setting -DLK. (Seems like there is something wrong with the register allocation.)
See https:/ /godbolt. org/z/yVgVC6
-Os...