Commit 2efdbf0f by Eric Botcazou Committed by Eric Botcazou

trans.c (can_equal_min_or_max_val_p): Be prepared for values outside of the range of the type.

	* gcc-interface/trans.c (can_equal_min_or_max_val_p): Be prepared for
	values outside of the range of the type.

From-SVN: r201692
parent b5f8f063
2013-08-13 Eric Botcazou <ebotcazou@adacore.com> 2013-08-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (can_equal_min_or_max_val_p): Be prepared for
values outside of the range of the type.
2013-08-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils2.c (build_atomic_load): Do a mere view-conversion * gcc-interface/utils2.c (build_atomic_load): Do a mere view-conversion
to the original type before converting to the result type. to the original type before converting to the result type.
(build_atomic_store): First do a conversion to the original type before (build_atomic_store): First do a conversion to the original type before
......
...@@ -2391,7 +2391,10 @@ can_equal_min_or_max_val_p (tree val, tree type, bool max) ...@@ -2391,7 +2391,10 @@ can_equal_min_or_max_val_p (tree val, tree type, bool max)
if (TREE_CODE (val) != INTEGER_CST) if (TREE_CODE (val) != INTEGER_CST)
return true; return true;
return tree_int_cst_equal (val, min_or_max_val) == 1; if (max)
return tree_int_cst_lt (val, min_or_max_val) == 0;
else
return tree_int_cst_lt (min_or_max_val, val) == 0;
} }
/* Return true if VAL (of type TYPE) can equal the minimum value of TYPE. /* Return true if VAL (of type TYPE) can equal the minimum value of TYPE.
......
2013-08-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/loop_optimization16.adb: New test.
* gnat.dg/loop_optimization16_pkg.ad[sb]: New helper.
2013-08-13 Marek Polacek <polacek@redhat.com> 2013-08-13 Marek Polacek <polacek@redhat.com>
* gcc.dg/pr57980.c: Use vector of two elements, not just one. * gcc.dg/pr57980.c: Use vector of two elements, not just one.
......
-- { dg-do run }
with Loop_Optimization16_Pkg; use Loop_Optimization16_Pkg;
procedure Loop_Optimization16 is
Counter : Natural := 0;
C : constant Natural := F;
subtype Index_T is Index_Base range 1 .. Index_Base (C);
begin
for I in Index_T'First .. Index_T'Last loop
Counter := Counter + 1;
exit when Counter > 200;
end loop;
if Counter > 200 then
raise Program_Error;
end if;
end Loop_Optimization16;
package body Loop_Optimization16_Pkg is
function F return Natural is
begin
return Natural (Index_Base'Last);
end;
end Loop_Optimization16_Pkg;
package Loop_Optimization16_Pkg is
type Index_Base is range 0 .. 127;
function F return Natural;
end Loop_Optimization16_Pkg;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment