diff mbox series

Change range_handler, was Re: Fix gimple_expr_code?

Message ID 8a87a017-c03e-3628-8960-fee6d970f791@redhat.com
State New
Headers show
Series Change range_handler, was Re: Fix gimple_expr_code? | expand

Commit Message

Andrew MacLeod Nov. 13, 2020, 12:30 a.m. UTC
On 11/12/20 4:12 PM, Andrew MacLeod via Gcc-patches wrote:
> On 11/12/20 3:53 PM, Richard Biener wrote: ... 😬
>>
>>> But it means that gimple_expr_code() isn't returning the correct result
>>>
>>> for GIMPLE_SINGLE_RHS....
>> It depends. A SSA name isn't an expression code either. As said, the 
>> generic gimple_expr_code should be used with extreme care.
>
> what is an expression code?  It seems like its just a  tree_code 
> representing what is on the RHS?    Im not sure I understand why one 
> needs to be careful with it.  It only applies to COND, ASSIGN and 
> CALL. and its current right for everything except GIMPLE_SINGLE_RHS?
>
> If we dont fix gimple_expr_code, then Im basically going to be 
> reimplementing it myself... which seems kind of pointless.
>
> Andrew
>
>
However, that said, It seems like reworking the accessor is probably 
better anyway.  Point taken on expr_type..  for a GIMPLE_COND I wasn't 
actually getting the type I really wanted as it turned out.

anyway, fixed thusly.

Bootstrapped on x86_64-pc-linux-gnu, no regressions.  pushed.

Andrew
commit ee24da1b983a89b05303f2ac8828dd8cbe28d3b4
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Thu Nov 12 19:25:59 2020 -0500

    Change range_handler, was  Re: Fix gimple_expr_code?
    
    Adjust the range_handler to not use gimple_expr_code/type.
    
            * gimple-range.h (gimple_range_handler): Use gimple_assign and
            gimple_cond routines to get type and code.
            * range-op.cc (range_op_handler): Check for integral types.
diff mbox series

Patch

diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h
index 0aa6d4672ee..88d2ada324b 100644
--- a/gcc/gimple-range.h
+++ b/gcc/gimple-range.h
@@ -97,8 +97,12 @@  extern bool gimple_range_calc_op2 (irange &r, const gimple *s,
 static inline range_operator *
 gimple_range_handler (const gimple *s)
 {
-  if ((gimple_code (s) == GIMPLE_ASSIGN) || (gimple_code (s) == GIMPLE_COND))
-    return range_op_handler (gimple_expr_code (s), gimple_expr_type (s));
+  if (gimple_code (s) == GIMPLE_ASSIGN)
+    return range_op_handler (gimple_assign_rhs_code (s),
+			     TREE_TYPE (gimple_assign_lhs (s)));
+  if (gimple_code (s) == GIMPLE_COND)
+    return range_op_handler (gimple_cond_code (s),
+			     TREE_TYPE (gimple_cond_lhs (s)));
   return NULL;
 }
 
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index aff9383d936..86d1af7fe54 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3341,10 +3341,12 @@  pointer_table::pointer_table ()
 range_operator *
 range_op_handler (enum tree_code code, tree type)
 {
-  // First check if there is apointer specialization.
+  // First check if there is a pointer specialization.
   if (POINTER_TYPE_P (type))
     return pointer_tree_table[code];
-  return integral_tree_table[code];
+  if (INTEGRAL_TYPE_P (type))
+    return integral_tree_table[code];
+  return NULL;
 }
 
 // Cast the range in R to TYPE.