diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 2598059280bf1666cf397d650ca26d1d717d7531..ca91a24795b1d783b4870932cca6268bffa20c1e 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -7557,9 +7557,12 @@
 	  (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))))]
   "TARGET_P8_VECTOR"
 {
-  if (vsx_register_operand (operands[0], <MODE>mode))
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
     return "xxleqv %x0,%x1,%x2";
 
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
+    return "veqv %0,%1,%2";
+
   return "#";
 }
   "TARGET_P8_VECTOR && reload_completed