This fixes an omission when moving tree-ssa-forwprop.c code to match.pd
in GCC 5 times.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2016-06-07  Richard Biener  <rguent...@suse.de>

        PR middle-end/71423
        * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
        for signed ops.

        * gcc.dg/torture/pr71423.c: New testcase.

Index: gcc/match.pd
===================================================================
*** gcc/match.pd        (revision 237117)
--- gcc/match.pd        (working copy)
*************** DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
*** 900,911 ****
    (ne (bit_and:c (bit_not @0) @1) integer_zerop)
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
         && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
!    (lt @0 @1)))
  (simplify
    (ne (bit_ior:c (bit_not @0) @1) integer_zerop)
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
         && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
!    (le @0 @1)))
  
  /* ~~x -> x */
  (simplify
--- 900,915 ----
    (ne (bit_and:c (bit_not @0) @1) integer_zerop)
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
         && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
!    (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
!     (lt @0 @1)
!     (gt @0 @1))))
  (simplify
    (ne (bit_ior:c (bit_not @0) @1) integer_zerop)
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
         && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
!    (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
!     (le @0 @1)
!     (ge @0 @1))))
  
  /* ~~x -> x */
  (simplify
Index: gcc/testsuite/gcc.dg/torture/pr71423.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr71423.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr71423.c      (working copy)
***************
*** 0 ****
--- 1,20 ----
+ /* { dg-do run } */
+ 
+ struct S1
+ {
+   int f1:1;
+ };
+ 
+ volatile struct S1 b = { 0 };
+ 
+ int
+ main ()
+ {
+   char c = b.f1;
+   b.f1 = 1; 
+ 
+   if (b.f1 > -1 || c)
+     __builtin_abort (); 
+ 
+   return 0; 
+ }

Reply via email to