GCC with patches for OS216
Revision | 0bcfd10047731bea91d5a7709d10d8e9177c3826 (tree) |
---|---|
Time | 2018-04-13 18:24:58 |
Author | Aldy Hernandez <aldyh@gcc....> |
Commiter | Aldy Hernandez |
Rewrite size_must_be_zero_p with irange infrastructure.
Rewrite size_must_be_zero_p with irange infrastructure. Previous
implementation did not get the bits in [7fff,ffff]. This fixes a
handful of regressions.
From-SVN: r259370
@@ -642,9 +642,25 @@ var_decl_component_p (tree var) | ||
642 | 642 | static bool |
643 | 643 | size_must_be_zero_p (tree size) |
644 | 644 | { |
645 | - return (integer_zerop (size) | |
646 | - || (TREE_CODE (size) == SSA_NAME | |
647 | - && irange (size).zero_p ())); | |
645 | + if (integer_zerop (size)) | |
646 | + return true; | |
647 | + | |
648 | + if (TREE_CODE (size) != SSA_NAME) | |
649 | + return false; | |
650 | + | |
651 | + tree type = TREE_TYPE (size); | |
652 | + int prec = TYPE_PRECISION (type); | |
653 | + | |
654 | + wide_int wone = wi::one (prec); | |
655 | + | |
656 | + /* Compute the value of SSIZE_MAX, the largest positive value that | |
657 | + can be stored in ssize_t, the signed counterpart of size_t. */ | |
658 | + wide_int ssize_max = wi::lshift (wi::one (prec), prec - 1) - 1; | |
659 | + | |
660 | + irange not_zero (type, wone, ssize_max); | |
661 | + irange size_range (size); | |
662 | + return (size_range.contains_p (0) | |
663 | + && size_range.intersect (not_zero).empty_p ()); | |
648 | 664 | } |
649 | 665 | |
650 | 666 | /* Fold function call to builtin mem{{,p}cpy,move}. Try to detect and |