LI77235: INEFFICIENT COMPARE WITH 32-BIT IMMEDIATES

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • ===== DESCRIPTION:
    xlC compile does not issue optimal code for compare with 32-bit
    immediates.
    
    extern "C" unsigned int eqFEFEEFEF(unsigned int *in)
    {
       unsigned int i = *in;
       if (i == 0xFEFEEFEF) i++;
       return i;
    }
    
    Output:
         | 000000                           PDEF     eqFEFEEFEF
       17|                                  PROC      in,gr3
       19| 000080 lwz      80830000   1     L4Z       gr4=(unsigned
    int)(gr3,0)
       20| 000084 ld       E8620018   1     L8
    gr3=.+CONSTANT_AREA (gr2,0)          <---- here
       20| 000088 ld       E8030000   1     L8
    gr0=+CONSTANT_AREA (gr3,0)           <---- here
       20| 00008C cmplw    7C040040   1     CL4       cr0=gr4,gr0
       20| 000090 bc       40820010   1     BF
    CL.23,cr0,0x4/eq,taken=50%(0,0)
       20| 000094 addi     38040001   1     AI        gr0=gr4,1
       20| 000098 rlwinm   5403003E   1     RN4
    gr3=gr0,0,0xFFFFFFFF
        0| 00009C bclr     4E800020   1     BA        lr
        0|                              CL.23:
       20| 0000A0 rlwinm   5483003E   1     RN4
    gr3=gr4,0,0xFFFFFFFF
       22| 0000A4 bclr     4E800020   1     BA        lr
    
    Optimal C input:
    extern "C" unsigned int eqFEFEEFEF_opt(unsigned int *in)
    {
       unsigned int i = *in;
       if ((i ^ 0xFEFE0000) == 0xEFEF) i++;
       return i;
    }
    
    Optimal output:
       26| 0000C0 lwz      80630000   1     L4Z       gr3=(unsigned
    int)(gr3,0)
       27| 0000C4 xoris    6C60FEFE   1     XIU       gr0=gr3,0xFEFE
       27| 0000C8 cmplwi   2800EFEF   1     CL4       cr0=gr0,61423
       27| 0000CC bc       40820010   1     BF
    CL.20,cr0,0x4/eq,taken=50%(0,0)
       27| 0000D0 addi     38830001   1     AI        gr4=gr3,1
       27| 0000D4 rlwinm   5483003E   1     RN4
    gr3=gr4,0,0xFFFFFFFF
        0| 0000D8 bclr     4E800020   1     BA        lr
        0|                              CL.20:
       27| 0000DC rlwinm   5463003E   1     RN4
    gr3=gr3,0,0xFFFFFFFF
       29| 0000E0 bclr     4E800020   1     BA        lr
    
    
    ===== TESTCASE:
    $ cat test.C
    extern "C" unsigned int eqFEFEEFEF(unsigned int *in)
    {
       unsigned int i = *in;
       if (i == 0xFEFEEFEF) i++;
       return i;
    }
    $
    
    ===== COMPILE COMMAND:
    xlC -q64 -O2 test.C -qlist -c
    

Local fix

  • n/a
    

Problem summary

  • USERS AFFECTED:
    Potentially any user of the compiler is affected by this issue.
    
    PROBLEM DESCRIPTION:
    When doing comparisons with large 32-bit constant values, we
    are generating 3 instructions; ie 2 to generate the constant,
    and 1 to do the comparison.
    When the comparison is a check for equality, we could
    accomplish it with 2 instructions.
    

Problem conclusion

  • Added code in the compiler to generate the 2 instruction
    sequence when appropriate.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI77235

  • Reported component name

    XL C/C++ FOR BG

  • Reported component ID

    5799AG100

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-02-21

  • Closed date

    2013-02-21

  • Last modified date

    2013-02-21

  • APAR is sysrouted FROM one or more of the following:

    IV33245

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ FOR BG

  • Fixed component ID

    5799AG100

Applicable component levels

  • RC10 PSY

       UP



Rate this page:

(0 users)Average rating

Document information


More support for:

XL C/C++ for Blue Gene/Q
Compiler

Software version:

12.1

Reference #:

LI77235

Modified date:

2013-02-21

Translate my page

Machine Translation

Content navigation