(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
s390/
zvector/
pr94613.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target s390_vx } */
       3  /* { dg-options "-O3 -mzarch -march=arch13 -mzvector -std=gnu99 --save-temps" } */
       4  
       5  #include <vecintrin.h>
       6  
       7  /* The initial implementation of vec_sel used an IF_THEN_ELSE rtx.
       8     This did NOT match what the vsel instruction does.  vsel is a
       9     bit-wise operation.  Using IF_THEN_ELSE made the + operation to be
      10     simplified away in combine.  A plus operation affects other bits in
      11     the same element. Hence per-element simplifications are wrong for
      12     vsel.  */
      13  vector unsigned char __attribute__((noinline))
      14  foo (vector unsigned char a, vector unsigned char b, vector unsigned char c)
      15  {
      16    return vec_sel (a + b, c, a);
      17  }
      18  
      19  /* FIXME: The OR operation still should be optimized away in that case.  */
      20  vector unsigned char __attribute__((noinline))
      21  bar (vector unsigned char a, vector unsigned char b, vector unsigned char c)
      22  {
      23    return vec_sel (a | b, c, a);
      24  }
      25  
      26  int
      27  main ()
      28  {
      29    vector unsigned char v = (vector unsigned char){ 1 };
      30  
      31    if (foo (v, v, v)[0] != 3)
      32        __builtin_abort ();
      33  
      34    if (bar (v, v, v)[0] != 1)
      35      __builtin_abort ();
      36  
      37    return 0;
      38  }