diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-09-24 14:45:13 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-09-24 14:45:13 +0200 |
commit | 81b405828fd0d3dca3eaf715e2008e7a95686b5c (patch) | |
tree | d35d8e4843a77813cecf244387d270f8956e49ea /gcc/match.pd | |
parent | 90acd49f6ba247e4549224c2178910aee95a2617 (diff) | |
download | gcc-81b405828fd0d3dca3eaf715e2008e7a95686b5c.zip gcc-81b405828fd0d3dca3eaf715e2008e7a95686b5c.tar.gz gcc-81b405828fd0d3dca3eaf715e2008e7a95686b5c.tar.bz2 |
re PR middle-end/91866 (Sign extend of an int is not recognized)
PR middle-end/91866
* match.pd (((T)(A)) + CST -> (T)(A + CST)): Formatting fix.
(((T)(A + CST1)) + CST2 -> (T)(A) + (T)CST1 + CST2): New optimization.
* gcc.dg/tree-ssa/pr91866.c: New test.
From-SVN: r276096
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 4fd7590..23ce3768 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2265,8 +2265,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) max_ovf = wi::OVF_OVERFLOW; tree inner_type = TREE_TYPE (@0); - wide_int w1 = wide_int::from (wi::to_wide (@1), TYPE_PRECISION (inner_type), - TYPE_SIGN (inner_type)); + wide_int w1 + = wide_int::from (wi::to_wide (@1), TYPE_PRECISION (inner_type), + TYPE_SIGN (inner_type)); wide_int wmin0, wmax0; if (get_range_info (@0, &wmin0, &wmax0) == VR_RANGE) @@ -2280,6 +2281,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ))) #endif +/* ((T)(A + CST1)) + CST2 -> (T)(A) + (T)CST1 + CST2 */ +#if GIMPLE + (for op (plus minus) + (simplify + (plus (convert:s (op:s @0 INTEGER_CST@1)) INTEGER_CST@2) + (if (TREE_CODE (TREE_TYPE (@0)) == INTEGER_TYPE + && TREE_CODE (type) == INTEGER_TYPE + && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@0)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) + && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0)) + && TYPE_OVERFLOW_WRAPS (type)) + (plus (convert @0) (op @2 (convert @1)))))) +#endif + /* ~A + A -> -1 */ (simplify (plus:c (bit_not @0) @0) |