llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

PPC Altivec: Killed - processing time exceeded

Open ltertan opened this issue 4 years ago • 12 comments

Testcase:

extern void flag(unsigned long);

static __inline__ int
vec_all_eq(vector unsigned char __a, vector unsigned char __b) {
  return __builtin_altivec_vcmpequb_p(2, (vector char)__a, (vector char)__b);
}

static __inline__ vector unsigned char
    vec_perm(vector unsigned char __a, vector unsigned char __b,
             vector unsigned char __c) {

  return (vector unsigned char)__builtin_altivec_vperm_4si(
      (vector int)__a, (vector int)__b, __c);
}

int t2(void) {
  unsigned long msr;

  __vector unsigned char a = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
                               0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF};

  __vector unsigned char b = {0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                               0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF};

  __vector unsigned char c = {0x01, 0x14, 0x18, 0x10, 0x06, 0x15,
                                  0x19, 0x1A, 0x1C, 0x1C, 0x1C, 0x13,
                                  0x08, 0x1D, 0x1B, 0x0E};

  __vector unsigned char s = {161, 180, 184, 176, 166, 181, 185, 186,
                                 188, 188, 188, 179, 168, 189, 187, 174};

  __vector unsigned char r;

  r = vec_perm(a, b, c);

  if (!vec_all_eq(s, r)) {
    flag(msr);
    return 1;
  }

  return 0;
}

Compile options:

-mcpu=a2 -msoft-float --target=ppc32 -O2 -maltivec

Error:

Killed - processing time exceeded
Compiler returned: 143

ltertan avatar May 18 '22 11:05 ltertan

@llvm/issue-subscribers-backend-powerpc

llvmbot avatar May 18 '22 13:05 llvmbot

I'll have a look. It seems that -msoft-float is disabling -maltivec.

nemanjai avatar May 18 '22 21:05 nemanjai

I'll have a look. It seems that -msoft-float is disabling -maltivec.

Maybe the same thing is happening with #55555 as well? If -msoft-float is removed from the other defect, it then compiles just fine.

ltertan avatar May 18 '22 22:05 ltertan

I looked at the code. Making Altivec dependent on hard float actually makes sense. Can you elaborate on the use case for Altivec with soft float?

nemanjai avatar May 19 '22 01:05 nemanjai

I was comparing this with GCC, but looking at the generated code when using -msoft-float and -mhard-float, GCC actually generates the same code -- probably they silently use -mhard-float instead.

I believe #55555 can be closed in the same manner, right? Will you do this, or shall I?

ltertan avatar May 19 '22 18:05 ltertan

I think it would be better from the perspective of usability if the compiler actually diagnosed this rather than doing weird things like crashing. What I have in mind is something like existing diagnostics for VSX and its sub-features:

$ clang -mno-vsx -mpower8-vector test.c -S
error: option '-mpower8-vector' cannot be specified with '-mno-vsx'

Except it would be something like: error: option '-msoft-float' cannot be specified with '-maltivec'

nemanjai avatar May 20 '22 12:05 nemanjai

Sounds good. I'll leave this defect open and close the other one.

ltertan avatar May 20 '22 13:05 ltertan

Proposed fix in https://reviews.llvm.org/D126302

nemanjai avatar May 24 '22 23:05 nemanjai

@nemanjai Hi, Nemanjai, is it possible to move https://reviews.llvm.org/D126302 to Github PR? Let me know if you need me or others to do it. Thank you.

chenzheng1030 avatar Jan 08 '24 02:01 chenzheng1030

@nemanjai Hi, Nemanjai, is it possible to move https://reviews.llvm.org/D126302 to Github PR? Let me know if you need me or others to do it. Thank you.

Hi @chenzheng1030 would you be able to take the patch over? TBH, I forgot about it.

nemanjai avatar Jan 22 '24 19:01 nemanjai

@nemanjai Hi, Nemanjai, is it possible to move https://reviews.llvm.org/D126302 to Github PR? Let me know if you need me or others to do it. Thank you.

Hi @chenzheng1030 would you be able to take the patch over? TBH, I forgot about it.

Sure, https://github.com/llvm/llvm-project/pull/79109 is posted

chenzheng1030 avatar Jan 23 '24 08:01 chenzheng1030

@llvm/issue-subscribers-clang-driver

Author: Laurentiu Tertan (ltertan)

**Testcase**:
extern void flag(unsigned long);

static __inline__ int
vec_all_eq(vector unsigned char __a, vector unsigned char __b) {
  return __builtin_altivec_vcmpequb_p(2, (vector char)__a, (vector char)__b);
}

static __inline__ vector unsigned char
    vec_perm(vector unsigned char __a, vector unsigned char __b,
             vector unsigned char __c) {

  return (vector unsigned char)__builtin_altivec_vperm_4si(
      (vector int)__a, (vector int)__b, __c);
}

int t2(void) {
  unsigned long msr;

  __vector unsigned char a = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
                               0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF};

  __vector unsigned char b = {0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                               0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF};

  __vector unsigned char c = {0x01, 0x14, 0x18, 0x10, 0x06, 0x15,
                                  0x19, 0x1A, 0x1C, 0x1C, 0x1C, 0x13,
                                  0x08, 0x1D, 0x1B, 0x0E};

  __vector unsigned char s = {161, 180, 184, 176, 166, 181, 185, 186,
                                 188, 188, 188, 179, 168, 189, 187, 174};

  __vector unsigned char r;

  r = vec_perm(a, b, c);

  if (!vec_all_eq(s, r)) {
    flag(msr);
    return 1;
  }

  return 0;
}

Compile options:

-mcpu=a2 -msoft-float --target=ppc32 -O2 -maltivec

Error:

Killed - processing time exceeded
Compiler returned: 143

llvmbot avatar Jan 26 '24 01:01 llvmbot