Fixes are available
APAR status
Closed as program error.
Error description
The compiler generates inefficient code for the following: ===== COMPILE COMMAND: xlC -q64 -O2 -qlist test.cpp ===== TESTCASE: $ cat test.cpp #define Uint64 unsigned long long Uint64 notZeroMask(Uint64 in) { return -(in != 0); } $ ===== ACTUAL OUTPUT: Looking at the listing file: Output: | 000000 PDEF notZeroMask(unsigned long long) | 000000 AKA notZeroMask__FUL 51| PROC in,gr3 53| 000160 addic 3003FFFF 1 ADDC gr0,ca=gr3,-1 53| 000164 addi 38600000 1 LI gr3=0 53| 000168 addze 7C030194 1 ADDE gr0,ca=gr3,0,ca 53| 00016C neg 7C8000D0 1 COMP gr4=gr0 53| 000170 extsw 7C8307B4 1 EXTS4 gr3=gr4 54| 000174 bclr 4E800020 1 BA lr ===== EXPECTED OUTPUT: Optimal output consists of subfic + subfe such as the one created using the following code: Uint64 notZeroMask_opt(Uint64 in) { Uint64 mask; asm("subfic %0, %1, 0; subfe %0,%0,%0" : "=r"(mask) : "r"(in) : "xer"); return mask; }
Local fix
N/A
Problem summary
USERS AFFECTED: Users who use the -(a!=0) syntax may be affected by this issue. PROBLEM DESCRIPTION: The compiler produces inefficient code for the -(a!=0) comparison.
Problem conclusion
The compiler now generates better code for Uint64 notZeroMask(Uint64 in) { return in != 0 ? 0xFFFFFFFFFFFFFFFFULL : 0ULL; } which is semantically equivalent to Uint64 notZeroMask(Uint64 in) { return -(in != 0); }
Temporary fix
Comments
APAR Information
APAR number
LI77936
Reported component name
XL C/C++ FOR LI
Reported component ID
5725C7300
Reported release
C10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2014-04-30
Closed date
2014-09-16
Last modified date
2014-09-16
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
XL C/C++ FOR LI
Fixed component ID
5725C7300
Applicable component levels
RC10 PSY
UP
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"12.1","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
16 October 2021