diff mbox

PR78501

Message ID CAAgBjMkQr3KWGhhWQKwF+wRTkgTHtRHAJRv=U9m1PjyUS0by7g@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni Nov. 24, 2016, 5:41 p.m. UTC
Hi,
The attached patch fixes ada bootstrap failure.
Bootstrap+tested on x86_64-unknown-linux-gnu with --enable-languages=all,ada
Cross-tested on aarch64*-*-*, arm*-*-* with --enable-languages=c,c++,fortran.
OK to commit ?

Thanks,
Prathamesh
2016-11-24  Jakub Jelinek  <jakub@redhat.com>
	    Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR middle-end/78501
	* tree-vrp.c (extract_range_basic): Check for ptrdiff_type_node to be
	non null and it's precision matches precision of lhs's type.

Comments

Richard Biener Nov. 25, 2016, 7:58 a.m. UTC | #1
On Thu, 24 Nov 2016, Prathamesh Kulkarni wrote:

> Hi,

> The attached patch fixes ada bootstrap failure.

> Bootstrap+tested on x86_64-unknown-linux-gnu with --enable-languages=all,ada

> Cross-tested on aarch64*-*-*, arm*-*-* with --enable-languages=c,c++,fortran.

> OK to commit ?


Ok.

Richard.
diff mbox

Patch

diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 33e0a75..8bea4db 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4028,15 +4028,20 @@  extract_range_basic (value_range *vr, gimple *stmt)
 	  }
 	  return;
 	case CFN_BUILT_IN_STRLEN:
-	  {
-	    tree type = TREE_TYPE (gimple_call_lhs (stmt));
-	    tree max = vrp_val_max (ptrdiff_type_node);
-	    wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
-	    tree range_min = build_zero_cst (type); 
-	    tree range_max = wide_int_to_tree (type, wmax - 1);
-	    set_value_range (vr, VR_RANGE, range_min, range_max, NULL);
-	  }
-	  return;
+	  if (tree lhs = gimple_call_lhs (stmt))
+	    if (ptrdiff_type_node
+		&& (TYPE_PRECISION (ptrdiff_type_node)
+		    == TYPE_PRECISION (TREE_TYPE (lhs))))
+	      {
+		tree type = TREE_TYPE (lhs);
+		tree max = vrp_val_max (ptrdiff_type_node);
+		wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
+		tree range_min = build_zero_cst (type);
+		tree range_max = wide_int_to_tree (type, wmax - 1);
+		set_value_range (vr, VR_RANGE, range_min, range_max, NULL);
+		return;
+	      }
+	  break;
 	default:
 	  break;
 	}