public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/106069] New: wrong code with -O -fno-tree-forwprop -maltivec on ppc64le
@ 2022-06-23 23:13 mpolacek at gcc dot gnu.org
  2022-06-23 23:15 ` [Bug target/106069] [12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-06-23 23:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106069
           Summary: wrong code with -O -fno-tree-forwprop -maltivec on
                    ppc64le
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

The following test crashes at runtime since r12-4496-g0910c516a3d72a.

$ ./cc1plus.r12-4495 -quiet -O -fno-tree-forwprop -maltivec q.C; g++ q.s;
./a.out
$ ./cc1plus.r12-4496 -quiet -O -fno-tree-forwprop -maltivec q.C; g++ q.s;
./a.out 
Aborted

Target: powerpc64le-unknown-linux-gnu
Configured with: /home/polacek/src/gcc/configure --enable-languages=c,c++
--enable-checking=yes -with-system-zlib --disable-bootstrap --disable-libvtv
--disable-libitm --disable-libsanitizer
gcc version 13.0.0 20220622 (experimental) (GCC)


extern "C" void *memcpy(void *, const void *, unsigned long);
typedef __attribute__((altivec(vector__))) unsigned native_simd_type;

union {
  native_simd_type V;
  int R[4];
} store_le_vec;

struct S {
  S() = default;
  S(unsigned B0) {
    native_simd_type val{B0};
    m_simd = val;
  }
  void store_le(unsigned char out[]) {
    store_le_vec.V = m_simd;
    unsigned int x0 = store_le_vec.R[0];
    memcpy(out, &x0, 1);
  }
  S rotl(unsigned int r) {
    native_simd_type rot{r};
    return __builtin_vec_rl(m_simd, rot);
  }
  void operator+=(S other) {
    m_simd = __builtin_vec_add(m_simd, other.m_simd);
  }
  void operator^=(S other) {
    m_simd = __builtin_vec_xor(m_simd, other.m_simd);
  }
  static void transpose(S &B0, S B1, S B2, S B3) {
    native_simd_type T0 = __builtin_vec_mergeh(B0.m_simd, B2.m_simd);
    native_simd_type T1 = __builtin_vec_mergeh(B1.m_simd, B3.m_simd);
    native_simd_type T2 = __builtin_vec_mergel(B0.m_simd, B2.m_simd);
    native_simd_type T3 = __builtin_vec_mergel(B1.m_simd, B3.m_simd);
    B0 = __builtin_vec_mergeh(T0, T1);
    B3 = __builtin_vec_mergel(T2, T3);
  }
  S(native_simd_type x) : m_simd(x) {}
  native_simd_type m_simd;
};

void
foo (unsigned char output[], unsigned state[])
{
  S R00 = state[0];
  S R01 = state[0];
  S R02 = state[2];
  S R03 = state[0];
  S R05 = state[5];
  S R06 = state[6];
  S R07 = state[7];
  S R08 = state[8];
  S R09 = state[9];
  S R10 = state[10];
  S R11 = state[11];
  S R12 = state[12];
  S R13 = state[13];
  S R14 = state[4];
  S R15 = state[15];
  for (int r = 0; r != 10; ++r) {
    R09 += R13;
    R11 += R15;
    R05 ^= R09;
    R06 ^= R10;
    R07 ^= R11;
    R07 = R07.rotl(7);
    R00 += R05;
    R01 += R06;
    R02 += R07;
    R15 ^= R00;
    R12 ^= R01;
    R13 ^= R02;
    R00 += R05;
    R01 += R06;
    R02 += R07;
    R15 ^= R00;
    R12 = R12.rotl(8);
    R13 = R13.rotl(8);
    R10 += R15;
    R11 += R12;
    R08 += R13;
    R09 += R14;
    R05 ^= R10;
    R06 ^= R11;
    R07 ^= R08;
    R05 = R05.rotl(7);
    R06 = R06.rotl(7);
    R07 = R07.rotl(7);
  }
  R00 += state[0];
  S::transpose(R00, R01, R02, R03);
  R00.store_le(output);
}

unsigned char res[1];
unsigned main_state[]{1634760805, 60878,      2036477234, 6,
                      0,          825562964,  1471091955, 1346092787,
                      506976774,  4197066702, 518848283,  118491664,
                      0,          0,          0,          0};
int
main ()
{
  foo (res, main_state);
  if (res[0] != 152)
    __builtin_abort();
}

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

end of thread, other threads:[~2023-05-08 12:24 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 23:13 [Bug target/106069] New: wrong code with -O -fno-tree-forwprop -maltivec on ppc64le mpolacek at gcc dot gnu.org
2022-06-23 23:15 ` [Bug target/106069] [12/13 Regression] " mpolacek at gcc dot gnu.org
2022-06-23 23:18 ` mpolacek at gcc dot gnu.org
2022-06-24  3:25 ` luoxhu at gcc dot gnu.org
2022-06-24 13:03 ` mpolacek at gcc dot gnu.org
2022-06-30  8:13 ` luoxhu at gcc dot gnu.org
2022-06-30  8:15 ` luoxhu at gcc dot gnu.org
2022-06-30 17:32 ` segher at gcc dot gnu.org
2022-06-30 17:34 ` segher at gcc dot gnu.org
2022-07-01  1:52 ` luoxhu at gcc dot gnu.org
2022-07-25 15:54 ` rguenth at gcc dot gnu.org
2022-07-25 20:16 ` segher at gcc dot gnu.org
2022-07-25 20:18 ` segher at gcc dot gnu.org
2022-07-26  3:34 ` luoxhu at gcc dot gnu.org
2022-07-26  3:34 ` luoxhu at gcc dot gnu.org
2022-07-26  3:35 ` luoxhu at gcc dot gnu.org
2022-07-26  3:53 ` luoxhu at gcc dot gnu.org
2022-07-26  6:28 ` luoxhu at gcc dot gnu.org
2022-07-29 11:10 ` rguenth at gcc dot gnu.org
2022-07-29 11:21 ` rguenth at gcc dot gnu.org
2022-08-03  6:10 ` yinyuefengyi at gmail dot com
2022-08-03  6:38 ` yinyuefengyi at gmail dot com
2022-08-03  8:06 ` linkw at gcc dot gnu.org
2022-08-03  8:24 ` rguenther at suse dot de
2022-08-03  8:50 ` linkw at gcc dot gnu.org
2022-08-03  8:59 ` rguenth at gcc dot gnu.org
2022-08-03  9:20 ` rsandifo at gcc dot gnu.org
2022-08-03  9:25 ` rsandifo at gcc dot gnu.org
2022-08-03 18:01 ` segher at gcc dot gnu.org
2022-08-03 18:06 ` segher at gcc dot gnu.org
2022-08-04  9:17 ` rsandifo at gcc dot gnu.org
2022-08-04  9:21 ` rearnsha at gcc dot gnu.org
2022-08-04  9:59 ` yinyuefengyi at gmail dot com
2022-08-04 10:01 ` yinyuefengyi at gmail dot com
2023-01-16 18:00 ` jakub at gcc dot gnu.org
2023-03-24 16:16 ` jakub at gcc dot gnu.org
2023-03-24 17:01 ` bergner at gcc dot gnu.org
2023-03-31  2:57 ` yinyuefengyi at gmail dot com
2023-05-08 12:24 ` [Bug target/106069] [12/13/14 " rguenth at gcc dot gnu.org

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).