View | Details | Return to bug 93744
Collapse All | Expand All

(-)gcc/match.pd.jj (-3 / +6 lines)
Lines 1472-1478 (define_operator_list COND_TERNARY Link Here
1472
(for cmp (gt lt ge le)
1472
(for cmp (gt lt ge le)
1473
(simplify
1473
(simplify
1474
 (mult (convert (cmp @0 @1)) @2)
1474
 (mult (convert (cmp @0 @1)) @2)
1475
  (cond (cmp @0 @1) @2 { build_zero_cst (type); })))
1475
  (if (GIMPLE || !TREE_SIDE_EFFECTS (@2))
1476
   (cond (cmp @0 @1) @2 { build_zero_cst (type); }))))
1476
1477
1477
/* For integral types with undefined overflow and C != 0 fold
1478
/* For integral types with undefined overflow and C != 0 fold
1478
   x * C EQ/NE y * C into x EQ/NE y.  */
1479
   x * C EQ/NE y * C into x EQ/NE y.  */
Lines 2709-2715 (define_operator_list COND_TERNARY Link Here
2709
       && TREE_CODE (TREE_TYPE (@4)) != BOOLEAN_TYPE
2710
       && TREE_CODE (TREE_TYPE (@4)) != BOOLEAN_TYPE
2710
       && INTEGRAL_TYPE_P (TREE_TYPE (@5))
2711
       && INTEGRAL_TYPE_P (TREE_TYPE (@5))
2711
       && (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
2712
       && (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
2712
	   || !TYPE_UNSIGNED (TREE_TYPE (@4))))
2713
	   || !TYPE_UNSIGNED (TREE_TYPE (@4)))
2714
       && (GIMPLE || !TREE_SIDE_EFFECTS (@1)))
2713
   (cond (cmp @2 @3) @1 @0)))
2715
   (cond (cmp @2 @3) @1 @0)))
2714
 (simplify
2716
 (simplify
2715
  (plus:c @0 (bit_and:c (minus @1 @0)
2717
  (plus:c @0 (bit_and:c (minus @1 @0)
Lines 2719-2725 (define_operator_list COND_TERNARY Link Here
2719
       && TREE_CODE (TREE_TYPE (@4)) != BOOLEAN_TYPE
2721
       && TREE_CODE (TREE_TYPE (@4)) != BOOLEAN_TYPE
2720
       && INTEGRAL_TYPE_P (TREE_TYPE (@5))
2722
       && INTEGRAL_TYPE_P (TREE_TYPE (@5))
2721
       && (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
2723
       && (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
2722
	   || !TYPE_UNSIGNED (TREE_TYPE (@4))))
2724
	   || !TYPE_UNSIGNED (TREE_TYPE (@4)))
2725
       && (GIMPLE || !TREE_SIDE_EFFECTS (@1)))
2723
   (cond (cmp @2 @3) @1 @0))))
2726
   (cond (cmp @2 @3) @1 @0))))
2724
2727
2725
/* Simplifications of shift and rotates.  */
2728
/* Simplifications of shift and rotates.  */
(-)gcc/testsuite/gcc.c-torture/execute/pr93744-1.c.jj (+14 lines)
Line 0 Link Here
1
/* PR tree-optimization/93744 */
2
3
typedef int I;
4
5
int
6
main ()
7
{
8
  int a = 0;
9
  I b = 0;
10
  (a > 0) * (b |= 2);
11
  if (b != 2)
12
    __builtin_abort ();
13
  return 0;
14
}
(-)gcc/testsuite/gcc.c-torture/execute/pr93744-2.c.jj (+21 lines)
Line 0 Link Here
1
/* PR tree-optimization/93744 */
2
3
int w;
4
5
int
6
foo (int x, int y, int z)
7
{
8
  int r = z - ((z - w++) & -(x < y));
9
  return r;
10
}
11
12
int
13
main ()
14
{
15
  w = 4;
16
  if (foo (5, 7, 12) != 4 || w != 5)
17
    __builtin_abort ();
18
  if (foo (7, 5, 12) != 12 || w != 6)
19
    __builtin_abort ();
20
  return 0;
21
}
(-)gcc/testsuite/gcc.c-torture/execute/pr93744-3.c.jj (+21 lines)
Line 0 Link Here
1
/* PR tree-optimization/93744 */
2
3
int w;
4
5
int
6
foo (int x, int y, int z)
7
{
8
  int r = z + ((w++ - z) & -(x < y));
9
  return r;
10
}
11
12
int
13
main ()
14
{
15
  w = 4;
16
  if (foo (5, 7, 12) != 4 || w != 5)
17
    __builtin_abort ();
18
  if (foo (7, 5, 12) != 12 || w != 6)
19
    __builtin_abort ();
20
  return 0;
21
}

Return to bug 93744