@@ -9381,7 +9381,15 @@ expand_expr_real_1 (tree exp, rtx target
{
if (GET_CODE (op0) == SUBREG)
op0 = force_reg (GET_MODE (op0), op0);
- op0 = gen_lowpart (mode, op0);
+ temp = gen_lowpart_common (mode, op0);
+ if (temp)
+ op0 = temp;
+ else
+ {
+ if (!REG_P (op0) && !MEM_P (op0))
+ op0 = force_reg (GET_MODE (op0), op0);
+ op0 = gen_lowpart (mode, op0);
+ }
}
/* If both types are integral, convert from one mode to the other. */
else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0)))
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/45728 */
+
+union U
+{
+ int *m;
+ double d;
+};
+
+int i;
+union U u;
+
+int
+foo (void)
+{
+ union U v = { &i };
+ return u.d == v.d;
+}