diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d5110c8d86b636fb6993e8cd3dd2ee5047d6f55..f460df6bd0deb75ebb17b6290f2ba44892b8dc7c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-15  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	* config/rs6000/rs6000.md (add<mode>3): Use reg_or_subregno instead
+	of REGNO.
+
 2017-06-14  Maciej W. Rozycki  <macro@imgtec.com>
 
 	* config/mips/mips.md (MIPS16_T_REGNUM): Remove constant.
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index dedb2e3c193310551ea5773506fdb3e7d16d4a19..8e1b460ee814b3b72d930e26a49c72aa19c7dfd0 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -1631,7 +1631,7 @@
 
       /* Adding a constant to r0 is not a valid insn, so use a different
 	 strategy in that case.  */
-      if (REGNO (operands[1]) == 0 || REGNO (tmp) == 0)
+      if (reg_or_subregno (operands[1]) == 0 || reg_or_subregno (tmp) == 0)
 	{
 	  if (operands[0] == operands[1])
 	    FAIL;