(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
s390/
md/
rXsbg_mode_sXl.c
       1  /* Machine description pattern tests.  */
       2  
       3  /*
       4      { dg-options "-mzarch -save-temps" }
       5  
       6     Note that dejagnu-1.5.1 has a bug so that the action from the second dg-do
       7     always wins, even if the condition is false.  If this test is run on hardware
       8     older than z10 with a buggy dejagnu release, the execution part will fail.
       9  
      10      { dg-do assemble }
      11      { dg-do run { target { s390_useable_hw } } }
      12  
      13     Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
      14     the command line:
      15  
      16      { dg-skip-if "" { *-*-* } { "-march=z9*" "-O0" } { "" } }
      17  
      18     Skip test if the -O or the -march= option is missing from the command line
      19     because it's difficult to detect the default:
      20  
      21      { dg-skip-if "" { *-*-* } { "*" } { "-O*" } }
      22      { dg-skip-if "" { *-*-* } { "*" } { "-march=*" } }
      23  */
      24  
      25  __attribute__ ((noinline)) unsigned int
      26  si_sll (unsigned int x)
      27  {
      28    return (x << 1);
      29  }
      30  
      31  __attribute__ ((noinline)) unsigned int
      32  si_srl (unsigned int x)
      33  {
      34    return (x >> 2);
      35  }
      36  
      37  __attribute__ ((noinline)) unsigned int
      38  rosbg_si_sll (unsigned int a, unsigned int b)
      39  {
      40    return a | (b << 1);
      41  }
      42  /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,32,62,1" 1 } } */
      43  
      44  __attribute__ ((noinline)) unsigned int
      45  rosbg_si_srl (unsigned int a, unsigned int b)
      46  {
      47    return a | (b >> 2);
      48  }
      49  /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,32,63,62" 1 } } */
      50  
      51  __attribute__ ((noinline)) unsigned int
      52  rxsbg_si_sll (unsigned int a, unsigned int b)
      53  {
      54    return a ^ (b << 1);
      55  }
      56  /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,32,62,1" 1 } } */
      57  
      58  __attribute__ ((noinline)) unsigned int
      59  rxsbg_si_srl (unsigned int a, unsigned int b)
      60  {
      61    return a ^ (b >> 2);
      62  }
      63  /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,32,63,62" 1 } } */
      64  
      65  __attribute__ ((noinline)) unsigned long long
      66  di_sll (unsigned long long x)
      67  {
      68    return (x << 1);
      69  }
      70  
      71  __attribute__ ((noinline)) unsigned long long
      72  di_srl (unsigned long long x)
      73  {
      74    return (x >> 2);
      75  }
      76  
      77  __attribute__ ((noinline)) unsigned long long
      78  rosbg_di_sll (unsigned long long a, unsigned long long b)
      79  {
      80    return a | (b << 1);
      81  }
      82  /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,0,62,1" 1 } } */
      83  
      84  __attribute__ ((noinline)) unsigned long long
      85  rosbg_di_srl (unsigned long long a, unsigned long long b)
      86  {
      87    return a | (b >> 2);
      88  }
      89  /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,2,63,62" 1 } } */
      90  
      91  __attribute__ ((noinline)) unsigned long long
      92  rxsbg_di_sll (unsigned long long a, unsigned long long b)
      93  {
      94    return a ^ (b << 1);
      95  }
      96  /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,0,62,1" 1 } } */
      97  
      98  __attribute__ ((noinline)) unsigned long long
      99  rxsbg_di_srl (unsigned long long a, unsigned long long b)
     100  {
     101    return a ^ (b >> 2);
     102  }
     103  /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,2,63,62" 1 } } */
     104  
     105  int
     106  main (void)
     107  {
     108    /* SIMode */
     109    {
     110      unsigned int r;
     111      unsigned int a = 0x12488421u;
     112      unsigned int b = 0x88881111u;
     113      unsigned int csll = si_sll (b);
     114      unsigned int csrl = si_srl (b);
     115  
     116      r = rosbg_si_sll (a, b);
     117      if (r != (a | csll))
     118        __builtin_abort ();
     119      r = rosbg_si_srl (a, b);
     120      if (r != (a | csrl))
     121        __builtin_abort ();
     122      r = rxsbg_si_sll (a, b);
     123      if (r != (a ^ csll))
     124        __builtin_abort ();
     125      r = rxsbg_si_srl (a, b);
     126      if (r != (a ^ csrl))
     127        __builtin_abort ();
     128    }
     129    /* DIMode */
     130    {
     131      unsigned long long r;
     132      unsigned long long a = 0x1248357997538421lu;
     133      unsigned long long b = 0x8888444422221111lu;
     134      unsigned long long csll = di_sll (b);
     135      unsigned long long csrl = di_srl (b);
     136  
     137      r = rosbg_di_sll (a, b);
     138      if (r != (a | csll))
     139        __builtin_abort ();
     140      r = rosbg_di_srl (a, b);
     141      if (r != (a | csrl))
     142        __builtin_abort ();
     143      r = rxsbg_di_sll (a, b);
     144      if (r != (a ^ csll))
     145        __builtin_abort ();
     146      r = rxsbg_di_srl (a, b);
     147      if (r != (a ^ csrl))
     148        __builtin_abort ();
     149    }
     150    return 0;
     151  }