testsuite: Also test swapped arguments of __builtin_mul_overflow_p [PR30314]
authorJakub Jelinek <jakub@redhat.com>
Thu, 2 Jun 2022 09:14:09 +0000 (11:14 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 2 Jun 2022 09:17:23 +0000 (11:17 +0200)
To test the commutativity of __builtin_mul_overflow* arguments in the
optimization, I've added 2 further tests.

2022-06-02  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/30314
* gcc.dg/tree-ssa/pr30314.c: Add tests with swapped arguments.

gcc/testsuite/gcc.dg/tree-ssa/pr30314.c

index 91388af..99e4ee2 100644 (file)
@@ -4,6 +4,8 @@
 /* { dg-final { scan-tree-dump-not "\.MUL_OVERFLOW " "optimized" } } */
 /* { dg-final { scan-tree-dump " > 122713351" "optimized" { target int32 } } } */
 /* { dg-final { scan-tree-dump " > 527049830677415760" "optimized" { target lp64 } } } */
+/* { dg-final { scan-tree-dump " > 102261126" "optimized" { target int32 } } } */
+/* { dg-final { scan-tree-dump " > 439208192231179800" "optimized" { target lp64 } } } */
 
 int
 foo (unsigned int x)
@@ -16,3 +18,15 @@ bar (unsigned long int x)
 {
   return __builtin_mul_overflow_p (x, 35UL, 0UL);
 }
+
+int
+baz (unsigned int x)
+{
+  return __builtin_mul_overflow_p (42, x, 0U);
+}
+
+int
+qux (unsigned long int x)
+{
+  return __builtin_mul_overflow_p (42, x, 0UL);
+}