tree-optimization/97089 - fix bogus unsigned division replacement
authorRichard Biener <rguenther@suse.de>
Fri, 18 Sep 2020 07:22:57 +0000 (09:22 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 18 Sep 2020 07:22:57 +0000 (09:22 +0200)
This fixes bogus replacing of an unsigned (-x)/y division by
-(x/y).

2020-09-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97089
* tree-ssa-sccvn.c (visit_nary_op): Do not replace unsigned
divisions.

gcc/tree-ssa-sccvn.c

index 64f1e8c9160772ae20b6b63adc6250819a01ba36..014b7bdfd01bd3ef5d14c3f54329515e60d50706 100644 (file)
@@ -4824,8 +4824,11 @@ visit_nary_op (tree lhs, gassign *stmt)
            }
        }
       break;
-    case RDIV_EXPR:
     case TRUNC_DIV_EXPR:
+      if (TYPE_UNSIGNED (type))
+       break;
+      /* Fallthru.  */
+    case RDIV_EXPR:
     case MULT_EXPR:
       /* Match up ([-]a){/,*}([-])b with v=a{/,*}b, replacing it with -v.  */
       if (! HONOR_SIGN_DEPENDENT_ROUNDING (type))