Index: gcc/tree-ssa-ccp.c
===================================================================
--- gcc/tree-ssa-ccp.c (revision 180237)
+++ gcc/tree-ssa-ccp.c (working copy)
@@ -500,20 +500,14 @@ value_to_double_int (prop_value_t val)
     return double_int_zero;
 }
 
-/* Return the value for the address expression EXPR based on alignment
-   information.  */
+/* Return the value for an expr of type TYPE with alignment ALIGN and offset
+   BITPOS relative to the alignment.  */
 
 static prop_value_t
-get_value_from_alignment (tree expr)
+get_align_value (unsigned int align, tree type, unsigned HOST_WIDE_INT bitpos)
 {
-  tree type = TREE_TYPE (expr);
   prop_value_t val;
-  unsigned HOST_WIDE_INT bitpos;
-  unsigned int align;
-
-  gcc_assert (TREE_CODE (expr) == ADDR_EXPR);
 
-  align = get_object_alignment_1 (TREE_OPERAND (expr, 0), &bitpos);
   val.mask
     = double_int_and_not (POINTER_TYPE_P (type) || TYPE_UNSIGNED (type)
 			  ? double_int_mask (TYPE_PRECISION (type))
@@ -529,6 +523,21 @@ get_value_from_alignment (tree expr)
   return val;
 }
 
+/* Return the value for the address expression EXPR based on alignment
+   information.  */
+
+static prop_value_t
+get_value_from_alignment (tree expr)
+{
+  unsigned int align;
+  unsigned HOST_WIDE_INT bitpos;
+
+  gcc_assert (TREE_CODE (expr) == ADDR_EXPR);
+
+  align = get_object_alignment_1 (TREE_OPERAND (expr, 0), &bitpos);
+  return get_align_value (align, TREE_TYPE (expr), bitpos);
+}
+
 /* Return the value for the tree operand EXPR.  If FOR_BITS_P is true
    return constant bits extracted from alignment information for
    invariant addresses.  */
@@ -541,10 +550,18 @@ get_value_for_expr (tree expr, bool for_
   if (TREE_CODE (expr) == SSA_NAME)
     {
       val = *get_value (expr);
-      if (for_bits_p
-	  && val.lattice_val == CONSTANT
+      if (!for_bits_p)
+	return val;
+
+      if (val.lattice_val == CONSTANT
 	  && TREE_CODE (val.value) == ADDR_EXPR)
 	val = get_value_from_alignment (val.value);
+      else if (val.lattice_val == VARYING
+	       && SSA_NAME_PTR_INFO (expr) != NULL
+	       && SSA_NAME_PTR_INFO (expr)->align > 1
+	       && SSA_NAME_PTR_INFO (expr)->misalign == 0)
+	val = get_align_value (SSA_NAME_PTR_INFO (expr)->align * BITS_PER_UNIT,
+			       TREE_TYPE (expr), 0);
     }
   else if (is_gimple_min_invariant (expr)
 	   && (!for_bits_p || TREE_CODE (expr) != ADDR_EXPR))
@@ -2018,12 +2035,105 @@ ccp_visit_stmt (gimple stmt, edge *taken
   return SSA_PROP_VARYING;
 }
 
+/* Find pointer dereferences that post-dominate function entry and set
+   ptr_info->align for those pointers, and propagate backward through pointer
+   arithmetic.  */
+
+static void
+deduce_alignment_from_dereferences (void)
+{
+  basic_block bb, entry;
+  gimple stmt, def;
+  unsigned int align;
+  tree memref, ptr, offset;
+  struct ptr_info_def *pi;
+
+  /* Needs to be the successor of entry, for CDI_POST_DOMINATORS.  */
+  entry = single_succ (ENTRY_BLOCK_PTR);
+
+  FOR_EACH_BB (bb)
+    {
+      gimple_stmt_iterator i;
+
+      if (!dominated_by_p (CDI_POST_DOMINATORS, entry, bb))
+	continue;
+
+      for (i = gsi_start_nondebug_bb (bb); !gsi_end_p (i);
+	   gsi_next_nondebug (&i))
+        {
+	  stmt = gsi_stmt (i);
+	  if (!is_gimple_assign (stmt))
+	    continue;
+
+	  if (gimple_assign_rhs_code (stmt) == MEM_REF)
+	    {
+	      memref = gimple_assign_rhs1 (stmt);
+
+	      align = TYPE_ALIGN (TREE_TYPE (memref)) / BITS_PER_UNIT;
+	      if (align == 1)
+		continue;
+
+	      offset = TREE_OPERAND (memref, 1);
+	      if (!host_integerp (offset, 0)
+		  || tree_low_cst (offset, 0) % align != 0)
+		continue;
+
+	      ptr = TREE_OPERAND (memref, 0);
+	    }
+	  else
+	    /* Todo: handle more cases.  */
+	    continue;
+
+	  if (TREE_CODE (ptr) == INTEGER_CST
+	      && host_integerp (ptr, 0)
+	      && tree_low_cst (ptr, 0) % align != 0)
+	    error ("misaligned pointer dereferenced");
+
+	  while (TREE_CODE (ptr) == SSA_NAME)
+	    {
+	      pi = get_ptr_info (ptr);
+	      if (pi->misalign != 0)
+		{
+		  error ("misaligned pointer dereferenced");
+		  break;
+		}
+
+	      if (pi->align >= align)
+		break;
+	      pi->align = align;
+
+	      if (SSA_NAME_IS_DEFAULT_DEF (ptr))
+		break;
+
+	      /* Propagate backwards over pointer arithmetic.  */
+	      def = SSA_NAME_DEF_STMT (ptr);
+	      if (!is_gimple_assign (def))
+		break;
+
+	      if (gimple_assign_rhs_code (def) == POINTER_PLUS_EXPR)
+		{
+		  offset = gimple_assign_rhs2 (def);
+		  if (!host_integerp (offset, 0)
+		      || tree_low_cst (offset, 0) % align != 0)
+		    break;
+
+		  ptr = gimple_assign_rhs1 (def);
+		}
+	      else
+		/* Todo: handle more cases.  */
+		break;
+	    }
+	}
+    }
+}
 
 /* Main entry point for SSA Conditional Constant Propagation.  */
 
 static unsigned int
 do_ssa_ccp (void)
 {
+  calculate_dominance_info (CDI_POST_DOMINATORS);
+  deduce_alignment_from_dereferences ();
   ccp_initialize ();
   ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
   if (ccp_finalize ())
Index: gcc/testsuite/gcc.target/arm/pr43814-2.c
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gcc.target/arm/pr43814-2.c (revision 0)
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -finline-functions -mno-unaligned-access -fdump-rtl-expand" } */
+
+typedef unsigned int size_t;
+extern void* memcpy (void *, const void *, size_t);
+
+typedef union JValue {
+  void* l;
+} JValue;
+typedef struct Object {
+  int x;
+} Object;
+
+extern __inline__ long long
+dvmGetArgLong (const unsigned int* args, int elem)
+{
+  long long val;
+  memcpy (&val, &args[elem], 8);
+  return val;
+}
+
+void
+Dalvik_sun_misc_Unsafe_getObject (const unsigned int* args, JValue* pResult)
+{
+  Object* obj = (Object*) args[1];
+  long long offset = dvmGetArgLong (args, 2);
+  Object** address = (Object**) (((unsigned char*) obj) + offset);
+  pResult->l = ((void*) *address);
+}
+
+/* { dg-final { scan-rtl-dump-times "memcpy" 0 "expand"} } */
+/* { dg-final { cleanup-tree-dump "expand" } } */
+
Index: gcc/testsuite/gcc.c-torture/unsorted/HIcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/HIcmp.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/HIcmp.c (working copy)
@@ -12,7 +12,7 @@ type glob0, glob1;
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/HIset.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/HIset.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/HIset.c (working copy)
@@ -8,7 +8,7 @@
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/SIcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/SIcmp.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/SIcmp.c (working copy)
@@ -12,7 +12,7 @@ type glob0, glob1;
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/SIset.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/SIset.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/SIset.c (working copy)
@@ -8,7 +8,7 @@
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/SFset.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/SFset.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/SFset.c (working copy)
@@ -8,7 +8,7 @@
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/UHIcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/UHIcmp.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/UHIcmp.c (working copy)
@@ -12,7 +12,7 @@ type glob0, glob1;
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/USIcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/USIcmp.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/USIcmp.c (working copy)
@@ -12,7 +12,7 @@ type glob0, glob1;
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
Index: gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c (revision 180237)
+++ gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c (working copy)
@@ -12,7 +12,7 @@ type glob0, glob1;
 #define adrx0 (E0[x0])
 #define regx0 (p0[x0])
 
-#define E1 ((type *)11111111)
+#define E1 ((type *)(11111111 & ~(sizeof (type) - 1)))
 #define reg1 r1
 #define indreg1 (*p1)
 #define imm1 33
