(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
riscv/
xtheadmempair-2.c
       1  /* { dg-do compile } */
       2  /* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-g" "-Oz" "-Os" "-flto" } } */
       3  /* { dg-options "-march=rv64gc_xtheadmempair -mtune=thead-c906" { target { rv64 } } } */
       4  /* { dg-options "-march=rv32gc_xtheadmempair -mtune=thead-c906" { target { rv32 } } } */
       5  
       6  #include <inttypes.h>
       7  
       8  #if __riscv_xlen == 32
       9  typedef uint32_t xlen_t;
      10  #else
      11  typedef uint64_t xlen_t;
      12  #endif
      13  
      14  #define SxD_TEST(f, T, i1, i2)		\
      15  void					\
      16  f ## i1 ## i2(T *arr, T x, T y)		\
      17  {					\
      18    arr[i1] = x;				\
      19    arr[i2] = y;				\
      20  }
      21  
      22  // works
      23  SxD_TEST(f, xlen_t, 0, 1)
      24  // does not work (can't merge with unaligned offset)
      25  SxD_TEST(f, xlen_t, 1, 2)
      26  // works
      27  SxD_TEST(f, xlen_t, 2, 3)
      28  // does not work (can't merge with unaligned offset)
      29  SxD_TEST(f, xlen_t, 3, 4)
      30  // works
      31  SxD_TEST(f, xlen_t, 4, 5)
      32  // does not work (can't merge with unaligned offset)
      33  SxD_TEST(f, xlen_t, 5, 6)
      34  // works
      35  SxD_TEST(f, xlen_t, 6, 7)
      36  // does not work (can't merge with unaligned offset)
      37  SxD_TEST(f, xlen_t, 7, 8)
      38  // does not work (out of range)
      39  SxD_TEST(f, xlen_t, 8, 9)
      40  
      41  // works with reordering
      42  SxD_TEST(r, xlen_t, 1, 0)
      43  // does not work (can't merge with unaligned offset)
      44  SxD_TEST(r, xlen_t, 2, 1)
      45  // works with reordering
      46  SxD_TEST(r, xlen_t, 3, 2)
      47  // does not work (can't merge with unaligned offset)
      48  SxD_TEST(r, xlen_t, 4, 3)
      49  // works with reordering
      50  SxD_TEST(r, xlen_t, 5, 4)
      51  // does not work (can't merge with unaligned offset)
      52  SxD_TEST(r, xlen_t, 6, 5)
      53  // works with reordering
      54  SxD_TEST(r, xlen_t, 7, 6)
      55  // does not work (can't merge with unaligned offset)
      56  SxD_TEST(r, xlen_t, 8, 7)
      57  // does not work (out of range)
      58  SxD_TEST(r, xlen_t, 9, 8)
      59  
      60  #if __riscv_xlen != 32
      61  // works
      62  SxD_TEST(w, uint32_t, 0, 1)
      63  // does not work (can't merge with unaligned offset)
      64  SxD_TEST(w, uint32_t, 1, 2)
      65  // works
      66  SxD_TEST(w, uint32_t, 2, 3)
      67  // does not work (can't merge with unaligned offset)
      68  SxD_TEST(w, uint32_t, 3, 4)
      69  // works
      70  SxD_TEST(w, uint32_t, 4, 5)
      71  // does not work (can't merge with unaligned offset)
      72  SxD_TEST(w, uint32_t, 5, 6)
      73  // works
      74  SxD_TEST(w, uint32_t, 6, 7)
      75  // does not work (can't merge with unaligned offset)
      76  SxD_TEST(w, uint32_t, 7, 8)
      77  // does not work (out of range)
      78  SxD_TEST(w, uint32_t, 8, 9)
      79  #endif
      80  
      81  /* { dg-final { scan-assembler-times "th.sdd\t" 8 { target { rv64 } } } } */
      82  /* { dg-final { scan-assembler-times "th.swd\t" 4 { target { rv64 } } } } */
      83  
      84  /* { dg-final { scan-assembler-times "th.swd\t" 8 { target { rv32 } } } } */