This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/54201] XMM constant duplicated
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 Aug 2012 13:20:26 +0000
- Subject: [Bug middle-end/54201] XMM constant duplicated
- Auto-submitted: auto-generated
- References: <bug-54201-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54201
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
|gnu.org |
--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-08-14 13:20:26 UTC ---
The following works.
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 190381)
+++ gcc/varasm.c (working copy)
@@ -3482,8 +3482,9 @@ force_const_mem (enum machine_mode mode,
{
struct constant_descriptor_rtx *desc, tmp;
struct rtx_constant_pool *pool;
+ enum machine_mode orig_mode = mode;
char label[256];
- rtx def, symbol;
+ rtx def, symbol, res;
hashval_t hash;
unsigned int align;
void **slot;
@@ -3500,6 +3501,18 @@ force_const_mem (enum machine_mode mode,
? shared_constant_pool
: crtl->varasm.pool);
+ /* Canonicalize CONST_VECTORs to the mode with the least number of
+ elements assuming that alignment requirements are not worse
+ for the original mode. */
+ if (GET_CODE (x) == CONST_VECTOR)
+ {
+ while (GET_MODE_SIZE (mode)
+ == GET_MODE_SIZE (GET_MODE_WIDER_MODE (mode)))
+ mode = GET_MODE_WIDER_MODE (mode);
+ x = simplify_subreg (mode, x, orig_mode, 0);
+ gcc_assert (x != NULL_RTX);
+ }
+
/* Lookup the value in the hashtable. */
tmp.constant = x;
tmp.mode = mode;
@@ -3509,7 +3522,11 @@ force_const_mem (enum machine_mode mode,
/* If the constant was already present, return its memory. */
if (desc)
- return copy_rtx (desc->mem);
+ {
+ res = copy_rtx (desc->mem);
+ PUT_MODE (res, orig_mode);
+ return res;
+ }
/* Otherwise, create a new descriptor. */
desc = ggc_alloc_constant_descriptor_rtx ();
@@ -3573,7 +3590,9 @@ force_const_mem (enum machine_mode mode,
if (GET_CODE (x) == LABEL_REF)
LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
- return copy_rtx (def);
+ res = copy_rtx (def);
+ PUT_MODE (res, orig_mode);
+ return res;
}
but we still create two references to the constant pool:
test:
.LFB517:
.cfi_startproc
pand .LC0(%rip), %xmm0
pcmpeqb .LC0(%rip), %xmm0
ret
Mine again.