Index: testsuite/gcc.dg/tm/memopt-15.c
===================================================================
--- testsuite/gcc.dg/tm/memopt-15.c	(revision 0)
+++ testsuite/gcc.dg/tm/memopt-15.c	(revision 0)
@@ -0,0 +1,30 @@
+/* { dg-do compile { target { x86_64-*-linux* } } } */
+/* { dg-options "-fgnu-tm -O" } */
+
+/* Test the TM vector logging functions.  */
+
+typedef int __attribute__((vector_size (16))) vectype;
+extern int something(void) __attribute__((transaction_safe));
+extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe));
+
+vectype vecky;
+
+vectype f()
+{
+  vectype *p;
+
+  p = malloc (sizeof (*p) * 100);
+
+  __transaction {
+    /* p[5] is thread private, but not transaction local since the
+       malloc is outside of the transaction.  We can use the logging
+       functions for this.  */
+    p[5] = vecky;
+
+    if (something())
+      __transaction_cancel;
+  }
+  return p[5];
+}
+
+/* { dg-final { scan-assembler "_ITM_LM128" } } */
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c	(revision 160538)
+++ tree-ssa-alias.c	(working copy)
@@ -1030,12 +1030,26 @@ ref_maybe_used_by_call_p_1 (gimple call,
         /* The following functions read memory pointed to by their
 	   first argument.  */
 	CASE_BUILT_IN_TM_LOAD (1):
-        CASE_BUILT_IN_TM_LOAD (2):
+	CASE_BUILT_IN_TM_LOAD (2):
 	CASE_BUILT_IN_TM_LOAD (4):
 	CASE_BUILT_IN_TM_LOAD (8):
         CASE_BUILT_IN_TM_LOAD (FLOAT):
 	CASE_BUILT_IN_TM_LOAD (DOUBLE):
 	CASE_BUILT_IN_TM_LOAD (LDOUBLE):
+	CASE_BUILT_IN_TM_LOAD (M64):
+	CASE_BUILT_IN_TM_LOAD (M128):
+	CASE_BUILT_IN_TM_LOAD (M256):
+        case BUILT_IN_TM_LOG:
+        case BUILT_IN_TM_LOG_1:
+        case BUILT_IN_TM_LOG_2:
+        case BUILT_IN_TM_LOG_4:
+        case BUILT_IN_TM_LOG_8:
+        case BUILT_IN_TM_LOG_FLOAT:
+        case BUILT_IN_TM_LOG_DOUBLE:
+        case BUILT_IN_TM_LOG_LDOUBLE:
+        case BUILT_IN_TM_LOG_M64:
+        case BUILT_IN_TM_LOG_M128:
+        case BUILT_IN_TM_LOG_M256:
 	  return ptr_deref_may_alias_ref_p_1 (gimple_call_arg (call, 0), ref);
 
 	/* The following builtins do not read from memory.  */
@@ -1227,6 +1241,9 @@ call_may_clobber_ref_p_1 (gimple call, a
         CASE_BUILT_IN_TM_STORE (FLOAT):
         CASE_BUILT_IN_TM_STORE (DOUBLE):
         CASE_BUILT_IN_TM_STORE (LDOUBLE):
+        CASE_BUILT_IN_TM_STORE (M64):
+        CASE_BUILT_IN_TM_STORE (M128):
+        CASE_BUILT_IN_TM_STORE (M256):
         case BUILT_IN_TM_MEMCPY:
         case BUILT_IN_TM_MEMMOVE:
 	  {
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 160538)
+++ trans-mem.c	(working copy)
@@ -1031,25 +1031,36 @@ tm_log_emit_stmt (tree addr, gimple stmt
   else if (type == long_double_type_node)
     code = BUILT_IN_TM_LOG_LDOUBLE;
   else if (host_integerp (size, 1))
-    switch (tree_low_cst (size, 1))
-      {
-      case 1:
-	code = BUILT_IN_TM_LOG_1;
-	break;
-      case 2:
-	code = BUILT_IN_TM_LOG_2;
-	break;
-      case 4:
-	code = BUILT_IN_TM_LOG_4;
-	break;
-      case 8:
-	code = BUILT_IN_TM_LOG_8;
-	break;
-      default:
-	/* FIXME: Add support for vector logging functions.  */
-	code = BUILT_IN_TM_LOG;
-	break;
-      }
+    {
+      unsigned int n = tree_low_cst (size, 1);
+      switch (n)
+	{
+	case 1:
+	  code = BUILT_IN_TM_LOG_1;
+	  break;
+	case 2:
+	  code = BUILT_IN_TM_LOG_2;
+	  break;
+	case 4:
+	  code = BUILT_IN_TM_LOG_4;
+	  break;
+	case 8:
+	  code = BUILT_IN_TM_LOG_8;
+	  break;
+	default:
+	  code = BUILT_IN_TM_LOG;
+	  if (TREE_CODE (type) == VECTOR_TYPE)
+	    {
+	      if (n == 8 && built_in_decls[BUILT_IN_TM_LOG_M64])
+		code = BUILT_IN_TM_LOG_M64;
+	      else if (n == 16 && built_in_decls[BUILT_IN_TM_LOG_M128])
+		code = BUILT_IN_TM_LOG_M128;
+	      else if (n == 32 && built_in_decls[BUILT_IN_TM_LOG_M256])
+		code = BUILT_IN_TM_LOG_M256;
+	    }
+	  break;
+	}
+    }
 
   addr = gimplify_addr (&gsi, addr);
   if (code == BUILT_IN_TM_LOG)
Index: calls.c
===================================================================
--- calls.c	(revision 160538)
+++ calls.c	(working copy)
@@ -487,6 +487,9 @@ special_function_p (const_tree fndecl, i
 	CASE_BUILT_IN_TM_STORE (FLOAT):
 	CASE_BUILT_IN_TM_STORE (DOUBLE):
 	CASE_BUILT_IN_TM_STORE (LDOUBLE):
+	CASE_BUILT_IN_TM_STORE (M64):
+	CASE_BUILT_IN_TM_STORE (M128):
+	CASE_BUILT_IN_TM_STORE (M256):
 	CASE_BUILT_IN_TM_LOAD (1):
 	CASE_BUILT_IN_TM_LOAD (2):
 	CASE_BUILT_IN_TM_LOAD (4):
@@ -494,6 +497,20 @@ special_function_p (const_tree fndecl, i
 	CASE_BUILT_IN_TM_LOAD (FLOAT):
 	CASE_BUILT_IN_TM_LOAD (DOUBLE):
 	CASE_BUILT_IN_TM_LOAD (LDOUBLE):
+	CASE_BUILT_IN_TM_LOAD (M64):
+	CASE_BUILT_IN_TM_LOAD (M128):
+	CASE_BUILT_IN_TM_LOAD (M256):
+	case BUILT_IN_TM_LOG:
+	case BUILT_IN_TM_LOG_1:
+	case BUILT_IN_TM_LOG_2:
+	case BUILT_IN_TM_LOG_4:
+	case BUILT_IN_TM_LOG_8:
+	case BUILT_IN_TM_LOG_FLOAT:
+	case BUILT_IN_TM_LOG_DOUBLE:
+	case BUILT_IN_TM_LOG_LDOUBLE:
+	case BUILT_IN_TM_LOG_M64:
+	case BUILT_IN_TM_LOG_M128:
+	case BUILT_IN_TM_LOG_M256:
 	  flags |= ECF_TM_OPS;
 	  break;
 	default:
Index: gtm-builtins.def
===================================================================
--- gtm-builtins.def	(revision 160538)
+++ gtm-builtins.def	(working copy)
@@ -30,21 +30,26 @@ DEF_TM_BUILTIN (BUILT_IN_TM_FREE, "_ITM_
 
 /* Logging builtins.  */
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_1, "_ITM_LU1",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_2, "_ITM_LU2",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_4, "_ITM_LU4",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_8, "_ITM_LU8",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_FLOAT, "_ITM_LF",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_DOUBLE, "_ITM_LD",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_LDOUBLE, "_ITM_LE",
-                BT_FN_VOID_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG, "_ITM_LB",
-                BT_FN_VOID_VPTR_SIZE, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+                BT_FN_VOID_VPTR_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
+
+/* These stubs should get defined in the backend if applicable.  */
+DEF_BUILTIN_STUB (BUILT_IN_TM_LOG_M64, "__builtin__ITM_LM64")
+DEF_BUILTIN_STUB (BUILT_IN_TM_LOG_M128, "__builtin__ITM_LM128")
+DEF_BUILTIN_STUB (BUILT_IN_TM_LOG_M256, "__builtin__ITM_LM256")
 
 /* Writes.
 
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 160538)
+++ tree-ssa-structalias.c	(working copy)
@@ -3760,6 +3760,9 @@ find_func_aliases (gimple t)
 	  CASE_BUILT_IN_TM_STORE (FLOAT):
 	  CASE_BUILT_IN_TM_STORE (DOUBLE):
 	  CASE_BUILT_IN_TM_STORE (LDOUBLE):
+	  CASE_BUILT_IN_TM_STORE (M64):
+	  CASE_BUILT_IN_TM_STORE (M128):
+	  CASE_BUILT_IN_TM_STORE (M256):
 	    {
 	      tree addr = gimple_call_arg (t, 0);
 	      tree src = gimple_call_arg (t, 1);
@@ -3779,6 +3782,9 @@ find_func_aliases (gimple t)
 	  CASE_BUILT_IN_TM_LOAD (FLOAT):
 	  CASE_BUILT_IN_TM_LOAD (DOUBLE):
 	  CASE_BUILT_IN_TM_LOAD (LDOUBLE):
+	  CASE_BUILT_IN_TM_LOAD (M64):
+	  CASE_BUILT_IN_TM_LOAD (M128):
+	  CASE_BUILT_IN_TM_LOAD (M256):
 	    {
 	      tree dest = gimple_call_lhs (t);
 	      tree addr = gimple_call_arg (t, 0);
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 160538)
+++ config/i386/i386.c	(working copy)
@@ -22602,6 +22602,10 @@ static const struct builtin_description 
   { OPTION_MASK_ISA_AVX, CODE_FOR_nothing, "__builtin__ITM_RaRM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAR_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
   { OPTION_MASK_ISA_AVX, CODE_FOR_nothing, "__builtin__ITM_RaWM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAW_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
   { OPTION_MASK_ISA_AVX, CODE_FOR_nothing, "__builtin__ITM_RfWM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RFW_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
+
+  { OPTION_MASK_ISA_MMX, CODE_FOR_nothing, "__builtin__ITM_LM64", (enum ix86_builtins) BUILT_IN_TM_LOG_M64, UNKNOWN, VOID_FTYPE_PCVOID },
+  { OPTION_MASK_ISA_SSE, CODE_FOR_nothing, "__builtin__ITM_LM128", (enum ix86_builtins) BUILT_IN_TM_LOG_M128, UNKNOWN, VOID_FTYPE_PCVOID },
+  { OPTION_MASK_ISA_AVX, CODE_FOR_nothing, "__builtin__ITM_LM256", (enum ix86_builtins) BUILT_IN_TM_LOG_M256, UNKNOWN, VOID_FTYPE_PCVOID },
 };
 
 /* TM callbacks.  */
@@ -22656,6 +22660,7 @@ ix86_init_tm_builtins (void)
   size_t i;
   tree decl;
   tree attrs_load, attrs_type_load, attrs_store, attrs_type_store;
+  tree attrs_log, attrs_type_log;
 
   if (!flag_tm)
     return;
@@ -22668,6 +22673,10 @@ ix86_init_tm_builtins (void)
   decl = built_in_decls[BUILT_IN_TM_STORE_1];
   attrs_store = DECL_ATTRIBUTES (decl);
   attrs_type_store = TYPE_ATTRIBUTES (TREE_TYPE (decl));
+  /* Use whatever attributes a normal TM log has.  */
+  decl = built_in_decls[BUILT_IN_TM_LOG];
+  attrs_log = DECL_ATTRIBUTES (decl);
+  attrs_type_log = TYPE_ATTRIBUTES (TREE_TYPE (decl));
 
   for (i = 0, d = bdesc_tm;
        i < ARRAY_SIZE (bdesc_tm);
@@ -22688,11 +22697,16 @@ ix86_init_tm_builtins (void)
 	      attrs = attrs_load;
 	      attrs_type = attrs_type_load;
 	    }
-	  else
+	  else if (BUILTIN_TM_STORE_P (code))
 	    {
 	      attrs = attrs_store;
 	      attrs_type = attrs_type_store;
 	    }
+	  else
+	    {
+	      attrs = attrs_log;
+	      attrs_type = attrs_type_log;
+	    }
 	  decl = add_builtin_function (d->name, type, code, BUILT_IN_NORMAL,
 				       /* The builtin without the prefix for
 					  calling it directly.  */
