]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-switch-conversion.c (emit_case_bit_tests): Generate MINUS_EXPR in unsigned type.
authorTom de Vries <tom@codesourcery.com>
Mon, 6 Aug 2012 08:32:20 +0000 (08:32 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 6 Aug 2012 08:32:20 +0000 (08:32 +0000)
2012-08-06  Tom de Vries  <tom@codesourcery.com>

* tree-switch-conversion.c (emit_case_bit_tests): Generate MINUS_EXPR in
unsigned type.

From-SVN: r190168

gcc/ChangeLog
gcc/tree-switch-conversion.c

index e228bfb2c6dc29630e4b9fcd1668be2e831081e6..2169ca5627e0a51cdd17d7bdaa0243ba30f9df6b 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-06  Tom de Vries  <tom@codesourcery.com>
+
+       * tree-switch-conversion.c (emit_case_bit_tests): Generate MINUS_EXPR in
+       unsigned type.
+
 2012-08-05  Venkataramanan Kumar  <venkataramanan.kumar@amd.com>
 
        * doc/invoke.texi: Document AMD btver2.
index 0630f1a5b93379efa25548e8df30023f4339f205..6c61eca3b612a99d27203707d29185e29b7a16c0 100644 (file)
@@ -384,10 +384,10 @@ emit_case_bit_tests (gimple swtch, tree index_expr,
 
   gsi = gsi_last_bb (switch_bb);
 
-  /* idx = (unsigned) (x - minval) */
-  idx = fold_build2 (MINUS_EXPR, index_type, index_expr,
-                    fold_convert (index_type, minval));
-  idx = fold_convert (unsigned_index_type, idx);
+  /* idx = (unsigned)x - minval.  */
+  idx = fold_convert (unsigned_index_type, index_expr);
+  idx = fold_build2 (MINUS_EXPR, unsigned_index_type, idx,
+                    fold_convert (unsigned_index_type, minval));
   idx = force_gimple_operand_gsi (&gsi, idx,
                                  /*simple=*/true, NULL_TREE,
                                  /*before=*/true, GSI_SAME_STMT);