(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
ands_2.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 --save-temps -fno-inline" } */
       3  
       4  extern void abort (void);
       5  
       6  int
       7  ands_si_test1 (int a, int b, int c)
       8  {
       9    int d = a & b;
      10  
      11    /* { dg-final { scan-assembler "ands\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */
      12    if (d <= 0)
      13      return a + c;
      14    else
      15      return b + d + c;
      16  }
      17  
      18  int
      19  ands_si_test2 (int a, int b, int c)
      20  {
      21    int d = a & 0x99999999;
      22  
      23    /* { dg-final { scan-assembler "ands\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } */
      24    if (d > 0)
      25      return b + d + c;
      26    else
      27      return a + c;
      28  }
      29  
      30  int
      31  ands_si_test3 (int a, int b, int c)
      32  {
      33    int d = a & (b << 3);
      34  
      35    /* { dg-final { scan-assembler "ands\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */
      36    if (d <= 0)
      37      return a + c;
      38    else
      39      return b + d + c;
      40  }
      41  
      42  typedef long long s64;
      43  
      44  s64
      45  ands_di_test1 (s64 a, s64 b, s64 c)
      46  {
      47    s64 d = a & b;
      48  
      49    /* { dg-final { scan-assembler "ands\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */
      50    if (d <= 0)
      51      return a + c;
      52    else
      53      return b + d + c;
      54  }
      55  
      56  s64
      57  ands_di_test2 (s64 a, s64 b, s64 c)
      58  {
      59    s64 d = a & 0xaaaaaaaaaaaaaaaall;
      60  
      61    /* { dg-final { scan-assembler "ands\tx\[0-9\]+, x\[0-9\]+, -6148914691236517206" } } */
      62    if (d > 0)
      63      return b + d + c;
      64    else
      65      return a + c;
      66  }
      67  
      68  s64
      69  ands_di_test3 (s64 a, s64 b, s64 c)
      70  {
      71    s64 d = a & (b << 3);
      72  
      73    /* { dg-final { scan-assembler "ands\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */
      74    if (d <= 0)
      75      return a + c;
      76    else
      77      return b + d + c;
      78  }
      79  
      80  int
      81  main ()
      82  {
      83    int x;
      84    s64 y;
      85  
      86    x = ands_si_test1 (29, 4, 5);
      87    if (x != 13)
      88      abort ();
      89  
      90    x = ands_si_test1 (5, 2, 20);
      91    if (x != 25)
      92      abort ();
      93  
      94    x = ands_si_test2 (29, 4, 5);
      95    if (x != 34)
      96      abort ();
      97  
      98    x = ands_si_test2 (1024, 2, 20);
      99    if (x != 1044)
     100      abort ();
     101  
     102    x = ands_si_test3 (35, 4, 5);
     103    if (x != 41)
     104      abort ();
     105  
     106    x = ands_si_test3 (5, 2, 20);
     107    if (x != 25)
     108      abort ();
     109  
     110    y = ands_di_test1 (0x130000029ll,
     111                       0x320000004ll,
     112                       0x505050505ll);
     113  
     114    if (y != ((0x130000029ll & 0x320000004ll) + 0x320000004ll + 0x505050505ll))
     115      abort ();
     116  
     117    y = ands_di_test1 (0x5000500050005ll,
     118                       0x2111211121112ll,
     119                       0x0000000002020ll);
     120    if (y != 0x5000500052025ll)
     121      abort ();
     122  
     123    y = ands_di_test2 (0x130000029ll,
     124                       0x320000004ll,
     125                       0x505050505ll);
     126    if (y != ((0x130000029ll & 0xaaaaaaaaaaaaaaaall) + 0x320000004ll + 0x505050505ll))
     127      abort ();
     128  
     129    y = ands_di_test2 (0x540004100ll,
     130                       0x320000004ll,
     131                       0x805050205ll);
     132    if (y != (0x540004100ll + 0x805050205ll))
     133      abort ();
     134  
     135    y = ands_di_test3 (0x130000029ll,
     136                       0x064000008ll,
     137                       0x505050505ll);
     138    if (y != ((0x130000029ll & (0x064000008ll << 3))
     139  	    + 0x064000008ll + 0x505050505ll))
     140      abort ();
     141  
     142    y = ands_di_test3 (0x130002900ll,
     143                       0x088000008ll,
     144                       0x505050505ll);
     145    if (y != (0x130002900ll + 0x505050505ll))
     146      abort ();
     147  
     148    return 0;
     149  }
     150