IBM Support

LI76563: INCORRECT CODE GEN WITH -QIPA

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling with -qipa, the test case below leads to an
    incorrect if-else being evaluated leading to an incorrect print
    statement being printed.
    
    ===== COMPILE COMMAND:
    xlC_r test.cpp -q64 -O0 -qipa
    
    ===== TESTCASE:
    $ cat test.cpp
    #include <stdio.h>
    
    #include "test.hpp"
    
    void check() {
        {
          printf(" contains (range) ");
          struct {
            bool stop; uint64_t from1; uint64_t to1; uint64_t from2;
    uint64_t to2; bool contains12; bool contains21;
          } data [] = {
            { false, 0, 0, 0, 0, true, true },
            { false, 0x1000, 0x2000, 0x1500, 0x1600, true, false },
            { false, 0x1000, 0x2000, 0x1000, 0x2000, true, true },
    #ifdef _LP64
            { false, 0, 0xFFFFFFFFFFFFFFFFULL,
    0xFFFFFFFFFFFFFFF0ULL, 0xFFFFFFFFFFFFFFF1ULL, true, false },
    #endif
            { true, 0, 0, 0, 0, false, false}
          };
    
          for (int i = 0; !data[i].stop; i ++) {
            printf(".");
            AddrRange r1((char*)data[i].from1, (char*)data[i].to1 -
    (char*)data[i].from1);
            AddrRange r2((char*)data[i].from2, (char*)data[i].to2 -
    (char*)data[i].from2);
    
            if(r1.contains(r2) == data[i].contains12) printf("+");
            else
    printf("fail\n");
            if(r2.contains(r1) == data[i].contains21) printf("+");
            else
    printf("fail\n");
          }
          printf("\n");
        }
    }
    
    int main( int argc, char** argv ) {
    
      printf("Starting test...\n");
      check();
    
      return 0;
    }
    
    
    $
    
    
    $ cat test.hpp
    
    
    
    
    class AddrRange {
    
      char* const _start;
      const size_t _size;
    
    public:
    
      AddrRange(char* start, size_t size)
        : _start(start), _size(size)
      {}
    
      AddrRange(const AddrRange& r)
        : _start(r.start()), _size(r.size())
      {}
    
      char* start() const { return _start; }
      size_t size() const { return _size; }
      char* end() const { return _start + _size; }
      bool is_empty() const { return _size == 0 ? true : false; }
    
      static AddrRange empty_range() { return AddrRange(NULL, 0); }
    
      bool contains(const char* p) const {
        return start() <= p && end() > p;
      }
    
      bool contains(const AddrRange& range) const {
        return start() <= range.start() && end() >= range.end();
      }
    
      bool intersects(const AddrRange& range) const {
        return (range.start() <= start() && range.end() > start())
    ||
               (range.start() < end() && range.end() >= end()) ||
               contains(range);
      }
    
      bool is_same_range(const AddrRange& range) const {
        return start() == range.start() && size() == range.size();
      }
    
      // return the closest inside range consisting of whole pages
      AddrRange find_closest_aligned_range(size_t pagesize) const;
    
    };
    
    
    $
    
    
    ===== ACTUAL OUTPUT:
    $ xlC_r test.cpp -q64 -O0 -qipa
    $ ./a.out
    Starting test...
     contains (range) .++.++.++.fail
    +
    $
    
    ===== EXPECTED OUTPUT:
    $ xlC_r test.cpp -q64 -O0 -qipa
    $ ./a.out
    Starting test...
     contains (range) .++.++.++.++
    $
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users of IPA with -O3 and above may be affected by this issue.
    
    PROBLEM DESCRIPTION:
    In certain cases, the compiler generates incorrect code for
    comparison with -qipa.
    In IPA there are various simplifications of expressions. For a
    specific expression,
    the compiler was already checking for cases where operands were
    integers, but did not have a check
    for the case where the operands where char* or DT_ADDRESS and
    they eventually get converted to integer.
    

Problem conclusion

  • The fix is to check for the char* or DT_ADDRESS possibility.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76563

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-01-09

  • Closed date

    2014-05-21

  • Last modified date

    2014-05-28

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

    IV03946

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

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels

  • RA10 PSY

       UP

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 October 2021