IBM Support

IV55854: INEFFICIENT CODE FOR -(A!=0)

Subscribe

You can track all active APARs for this component.

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

    IV55854

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-02-25

  • 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:

    LI77936

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels

  • RC10 PSY

       UP



Document information

More support for: XL C for AIX
Compiler

Software version: 12.1

Reference #: IV55854

Modified date: 16 September 2014