On 5/27/22 15:33, Andi Kleen wrote:
Andrew MacLeod via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
diff --git a/gcc/gimple-range-side-effect.cc b/gcc/gimple-range-side-effect.cc
index 2c8c77dc569..548e4bea313 100644
--- a/gcc/gimple-range-side-effect.cc
+++ b/gcc/gimple-range-side-effect.cc
@@ -116,6 +116,23 @@ stmt_side_effects::stmt_side_effects (gimple *s)
walk_stmt_load_store_ops (s, (void *)this, non_null_loadstore,
non_null_loadstore);
+ if (is_a<gassign *> (s))
+ {
+ switch (gimple_assign_rhs_code (s))
+ {
+ case TRUNC_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case EXACT_DIV_EXPR:
+ // Divide means operand 2 is not zero after this stmt.
+ if (gimple_range_ssa_p (gimple_assign_rhs2 (s)))
+ add_nonzero (gimple_assign_rhs2 (s));
Sorry I'm late, but how does this ensure the value is a integer?
I believe for floating point the assumption is not correct because
division by zero doesn't necessarily fault.
-Andi
gimple_range_ssa_p() only returns non-zero when the value is an ssa_name
whose type is supported by the range calculators... currently only
integrals values. When we support floating points we will have to add
additional logic.
Andrew