diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index a20a61c5dddbc80b23a9489d925a2c31b2163458..8ba5864efb33ffa5d1ced99f6a7d0c73e12560d5 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -6354,6 +6354,19 @@ simplify_const_relational_operation (enum rtx_code code,
 	return 0;
     }
 
+  /* Check if the operands are a vector EQ or NE comparison.  */
+  if (VECTOR_MODE_P (mode)
+      && INTEGRAL_MODE_P (mode)
+      && GET_CODE (op0) == CONST_VECTOR
+      && GET_CODE (op1) == CONST_VECTOR
+      && (code == EQ || code == NE))
+    {
+      if (rtx_equal_p (op0, op1))
+	return code == EQ ? const_true_rtx : const0_rtx;
+      else
+	return code == NE ? const_true_rtx : const0_rtx;
+    }
+
   /* We can't simplify MODE_CC values since we don't know what the
      actual comparison is.  */
   if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC)
@@ -8797,6 +8810,34 @@ test_vector_subregs (machine_mode inner_mode)
   test_vector_subregs_stepped (inner_mode);
 }
 
+/* Verify vector constant comparisons for EQ and NE.  */
+
+static void
+test_vector_int_const_compare (machine_mode mode)
+{
+  rtx zeros = CONST0_RTX (mode);
+  rtx minusone = CONSTM1_RTX (mode);
+  rtx series_0_1 = gen_const_vec_series (mode, const0_rtx, const1_rtx);
+  ASSERT_RTX_EQ (const0_rtx,
+		 simplify_const_relational_operation (EQ, mode, zeros,
+						      CONST1_RTX (mode)));
+  ASSERT_RTX_EQ (const_true_rtx,
+		 simplify_const_relational_operation (EQ, mode, zeros,
+						      CONST0_RTX (mode)));
+  ASSERT_RTX_EQ (const_true_rtx,
+		 simplify_const_relational_operation (EQ, mode, minusone,
+						      CONSTM1_RTX (mode)));
+  ASSERT_RTX_EQ (const_true_rtx,
+		 simplify_const_relational_operation (NE, mode, zeros,
+						      CONST1_RTX (mode)));
+  ASSERT_RTX_EQ (const_true_rtx,
+		 simplify_const_relational_operation (NE, mode, zeros,
+						      series_0_1));
+  ASSERT_RTX_EQ (const0_rtx,
+		 simplify_const_relational_operation (EQ, mode, zeros,
+						      series_0_1));
+}
+
 /* Verify some simplifications involving vectors.  */
 
 static void
@@ -8814,6 +8855,7 @@ test_vector_ops ()
 	    {
 	      test_vector_ops_series (mode, scalar_reg);
 	      test_vector_subregs (mode);
+	      test_vector_int_const_compare (mode);
 	    }
 	  test_vec_merge (mode);
 	}
