public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110598] New: [14 Regression] wrong code on llvm-14.0.6
@ 2023-07-08 17:00 slyfox at gcc dot gnu.org
  2023-07-08 17:32 ` [Bug target/110598] [14 Regression] wrong code on llvm-14.0.6 due to memcmp being miscompiled pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: slyfox at gcc dot gnu.org @ 2023-07-08 17:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110598

            Bug ID: 110598
           Summary: [14 Regression] wrong code on llvm-14.0.6
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Initially observed the failure as llvm-14.0.6 testsuite hangup on gcc
15bbf1826a01f5beb2d7c0f74d6270bbc94ece91.

Initially observed on
llvm-src-14.0.6/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp code
around 
    'AMDGPUPropagateAttributes::FnProperties:: bool operator == (const
FnProperties &Other) const' miscompilation.

Managed to extract the following example form it:

// $ cat bug.cpp
#include <iterator>

typedef unsigned long long u64;

const unsigned MAX_SUBTARGET_WORDS = 4;

struct FeatureBitset {
  u64 Bits[MAX_SUBTARGET_WORDS] = {0, 0, 0, 0};

  constexpr FeatureBitset() = default;
  constexpr FeatureBitset(std::initializer_list<unsigned> Init) {
    for (auto I : Init) {
      Bits[I] = 1;
    }
  }

  constexpr FeatureBitset operator&(const FeatureBitset &RHS) const {
    FeatureBitset Result = *this;
    for (unsigned I = 0, E = MAX_SUBTARGET_WORDS; I != E; ++I) {
      Result.Bits[I] &= RHS.Bits[I];
    }
    return Result;
  }

  bool operator!=(const FeatureBitset &RHS) const {
      return !std::equal(std::begin(Bits), std::end(Bits),
std::begin(RHS.Bits));
  }
};

static constexpr const FeatureBitset TargetFeatures = { 0, 0, 0, 0, };

__attribute__((noipa))
bool is_eq_buggy (const FeatureBitset & lf, const FeatureBitset & rf) {
  if ((lf & TargetFeatures) != (rf & TargetFeatures))
    return false;
  return true;
}

__attribute__((noipa))
void bug(void) {
    FeatureBitset lf, rf;
    lf.Bits[0] = rf.Bits[0] = 1;
    lf.Bits[1] = rf.Bits[1] = 1;
    lf.Bits[2] = rf.Bits[2] = 1;
    lf.Bits[3] = rf.Bits[3] = 1;

    bool r = is_eq_buggy (lf, rf);
    if (!r) __builtin_trap();
}

__attribute__((noipa))
int main(void) {
    bug();
}

Triggering:

$ g++ -O1 bug.cpp -o bug "$@" && ./bug
# ok
$ g++ -O2 bug.cpp -o bug "$@" && ./bug
Illegal instruction     (core dumped) ./bug

$ g++ -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/g++
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../source/configure --prefix=/<<NIX>>/gcc-14.0.0
--with-gmp-include=/<<NIX>>/gmp-6.2.1-dev/include
--with-gmp-lib=/<<NIX>>/gmp-6.2.1/lib
--with-mpfr-include=/<<NIX>>/mpfr-4.2.0-dev/include
--with-mpfr-lib=/<<NIX>>/mpfr-4.2.0/lib --with-mpc=/<<NIX>>/libmpc-1.3.1
--with-native-system-header-dir=/<<NIX>>/glibc-2.37-8-dev/include
--with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch
--without-included-gettext --with-system-zlib --enable-checking=release
--enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin
--disable-libcc1 --with-isl=/<<NIX>>/isl-0.20 --disable-bootstrap
--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
--target=x86_64-unknown-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-12 19:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-08 17:00 [Bug c++/110598] New: [14 Regression] wrong code on llvm-14.0.6 slyfox at gcc dot gnu.org
2023-07-08 17:32 ` [Bug target/110598] [14 Regression] wrong code on llvm-14.0.6 due to memcmp being miscompiled pinskia at gcc dot gnu.org
2023-07-08 17:41 ` pinskia at gcc dot gnu.org
2023-07-08 20:31 ` slyfox at gcc dot gnu.org
2023-07-09 22:34 ` roger at nextmovesoftware dot com
2023-07-12 13:13 ` cvs-commit at gcc dot gnu.org
2023-07-12 16:15 ` slyfox at gcc dot gnu.org
2023-07-12 19:42 ` roger at nextmovesoftware dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).