1 /* PR tree-optimization/61839. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-evrp" } */
4 /* { dg-require-effective-target int32plus } */
5
6 __attribute__ ((noinline))
foo()7 int foo ()
8 {
9 int a = -1;
10 volatile unsigned b = 1U;
11 int c = 1;
12 c = (a + 972195718) / (b ? 2 : 0);
13 if (c == 486097858)
14 ;
15 else
16 __builtin_abort ();
17 return 0;
18 }
19
20 __attribute__ ((noinline))
bar()21 int bar ()
22 {
23 int a = -1;
24 volatile unsigned b = 1U;
25 int c = 1;
26 c = (a + 972195718) % (b ? 2 : 0);
27 if (c == 1)
28 ;
29 else
30 __builtin_abort ();
31 return 0;
32 }
33
34 __attribute__ ((noinline))
bar2()35 int bar2 ()
36 {
37 int a = -1;
38 volatile unsigned b = 1U;
39 int c = 1;
40 c = (a + 972195716) % (b ? 1 : 2);
41 if (c == 0)
42 ;
43 else
44 __builtin_abort ();
45 return 0;
46 }
47
48
49 /* Dont optimize 972195717 / 0 in function foo. */
50 /* { dg-final { scan-tree-dump-times "972195717 / " 1 "evrp" } } */
51 /* Dont optimize 972195717 % 0 in function bar. */
52 /* { dg-final { scan-tree-dump-times "972195717 % " 1 "evrp" } } */
53 /* May optimize in function bar2, but EVRP doesn't perform this yet. */
54 /* { dg-final { scan-tree-dump-times "972195715 % " 0 "evrp" { xfail *-*-* } } } */
55