diff options
author | Jakub Jelinek <jakub@redhat.com> | 2014-10-15 12:33:02 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2014-10-15 12:33:02 +0200 |
commit | db247aed5ebb6e8995f24f5e12f4acde8ee52ce5 (patch) | |
tree | 4f7b3a2f04fe397428dc9d83c92631b4272f109f /gcc/tree-ssa-reassoc.c | |
parent | d110c3ed97ac3a7083fa32f7f1f53984ebdf1d92 (diff) | |
download | gcc-db247aed5ebb6e8995f24f5e12f4acde8ee52ce5.tar.gz |
tree-ssa-reassoc.c (optimize_range_tests_diff): Perform MINUS_EXPR in unsigned type to avoid undefined behavior.
* tree-ssa-reassoc.c (optimize_range_tests_diff): Perform
MINUS_EXPR in unsigned type to avoid undefined behavior.
From-SVN: r216252
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 2e8337c8e6f..4714a389eb3 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -2250,8 +2250,13 @@ optimize_range_tests_diff (enum tree_code opcode, tree type, if (tree_log2 (tem1) < 0) return false; + type = unsigned_type_for (type); + tem1 = fold_convert (type, tem1); + tem2 = fold_convert (type, tem2); + lowi = fold_convert (type, lowi); mask = fold_build1 (BIT_NOT_EXPR, type, tem1); - tem1 = fold_binary (MINUS_EXPR, type, rangei->exp, lowi); + tem1 = fold_binary (MINUS_EXPR, type, + fold_convert (type, rangei->exp), lowi); tem1 = fold_build2 (BIT_AND_EXPR, type, tem1, mask); lowj = build_int_cst (type, 0); if (update_range_test (rangei, rangej, 1, opcode, ops, tem1, |