[Bug tree-optimization/114965] [13/14/15 Regression] wrong code generated for Emacs/Gnulib strftime (regression from 13.2)
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 7 11:49:46 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114965
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Untested fix.
If entry_test_needed, earlier code ensures that exp is in [lowi, high] range,
so the optimization is ok. But without it, we need to ensure that if we lower
lowi we can still do the shifts safely.
r in this case is [43,43][48,48][95,95], so we don't need entry test if we
subtract the low bound (43), but 95 is too high for 64-bit prec.
--- gcc/tree-ssa-reassoc.cc.jj 2023-10-15 23:04:06.181422840 +0200
+++ gcc/tree-ssa-reassoc.cc 2024-05-07 13:46:42.722966813 +0200
@@ -3414,7 +3414,8 @@ optimize_range_tests_to_bit_test (enum t
We can avoid then subtraction of the minimum value, but the
mask constant could be perhaps more expensive. */
if (compare_tree_int (lowi, 0) > 0
- && compare_tree_int (high, prec) < 0)
+ && compare_tree_int (high, prec) < 0
+ && (entry_test_needed || wi::ltu_p (r.upper_bound (), prec)))
{
int cost_diff;
HOST_WIDE_INT m = tree_to_uhwi (lowi);
More information about the Gcc-bugs
mailing list