if (INTVAL (op3) == 1)
{
+ if (INTVAL (op2) < 2 || INTVAL (op2) > 3)
+ {
+ error ("invalid third argument");
+ return const0_rtx;
+ }
+
if (TARGET_64BIT && TARGET_PREFETCHI
&& local_func_symbolic_operand (op0, GET_MODE (op0)))
emit_insn (gen_prefetchi (op0, op2));
op0 = copy_addr_to_reg (op0);
}
+ if (INTVAL (op2) < 0 || INTVAL (op2) > 3)
+ {
+ warning (0, "invalid third argument to %<__builtin_ia32_prefetch%>; using zero");
+ op2 = const0_rtx;
+ }
+
if (TARGET_3DNOW || TARGET_PREFETCH_SSE
|| TARGET_PRFCHW || TARGET_PREFETCHWT1)
emit_insn (gen_prefetch (op0, op1, op2));
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-mprefetchi" } */
+
+int
+foo (int a)
+{
+ return a + 1;
+}
+
+void
+bad (int *p)
+{
+ __builtin_ia32_prefetch (p, 0, 4, 0); /* { dg-warning "invalid third argument to '__builtin_ia32_prefetch'; using zero" } */
+ __builtin_ia32_prefetch (foo, 0, 4, 1); /* { dg-error "invalid third argument" } */
+}