(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr104992.c
       1  /* PR tree-optimization/104992 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-O2 -Wno-psabi -fdump-tree-optimized" } */
       4  
       5  #define vector __attribute__((vector_size(4*sizeof(int))))
       6  
       7  /* Form from PR.  */
       8  __attribute__((noipa)) unsigned foo(unsigned x, unsigned y)
       9  {
      10      return x / y * y == x;
      11  }
      12  
      13  __attribute__((noipa)) unsigned bar(unsigned x, unsigned y) {
      14      return x == x / y * y;
      15  }
      16  
      17  /* Signed test case.  */
      18  __attribute__((noipa)) unsigned baz (int x, int y) {
      19      return x / y * y == x;
      20  }
      21  
      22  /* Changed order.  */
      23  __attribute__((noipa)) unsigned qux (unsigned x, unsigned y) {
      24      return y * (x / y) == x;
      25  }
      26  
      27  /* Test for forward propogation.  */
      28  __attribute__((noipa)) unsigned corge(unsigned x, unsigned y) {
      29      int z = x / y;
      30      int q = z * y;
      31      return q == x; 
      32  }
      33  
      34  /* Test vector case.  */
      35  __attribute__((noipa)) vector int thud(vector int x, vector int y) {
      36      return x / y * y == x;
      37  }
      38  
      39  /* Complex type should not simplify because mod is different.  */
      40  __attribute__((noipa)) int goo(_Complex int x, _Complex int y)
      41  {
      42      _Complex int z = x / y;
      43      _Complex int q = z * y;
      44      return q == x; 
      45  }
      46  
      47  /* Wrong order.  */
      48  __attribute__((noipa)) unsigned fred (unsigned x, unsigned y) {
      49      return y * x / y == x;
      50  }
      51  
      52  /* Wrong pattern.  */
      53  __attribute__((noipa)) unsigned waldo (unsigned x, unsigned y, unsigned z) {
      54      return x / y * z == x;
      55  }
      56  
      57  /* { dg-final { scan-tree-dump-times " % " 9 "optimized" { target { ! vect_int_mod } } } } */
      58  /* { dg-final { scan-tree-dump-times " % " 6 "optimized" { target vect_int_mod } } } */