diff mbox

Fix PR71976 in combine.c:get_last_value()

Message ID c915e6f5-ba76-ab2b-db60-43e129af4830@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay July 29, 2016, 8:56 a.m. UTC
The issue with wrong-code bug PR71976 is that combine.c:get_last_value was 
called for a hard register in a wider mode (DImode) than the stored value had 
(QImode).  The patch introduces a test of the mode precision and only returns 
the recorded value if the according mode is not smaller than the mode for which 
get_last_value is called.

Segher already tested the patch on 32 different (sub-)architectures of Linux 
without any regression, cf.

https://gcc.gnu.org/ml/gcc/2016-07/msg00215.html

Ok for trunk and to backport?


Johann

gcc/
	PR rtl-optimization/71976
	* combine.c (get_last_value): Return 0 if the argument for which
	the function is called has a wider mode than the recorded value.

Comments

Segher Boessenkool July 29, 2016, 9:19 a.m. UTC | #1
On Fri, Jul 29, 2016 at 10:56:22AM +0200, Georg-Johann Lay wrote:
> The issue with wrong-code bug PR71976 is that combine.c:get_last_value was 
> called for a hard register in a wider mode (DImode) than the stored value 
> had (QImode).  The patch introduces a test of the mode precision and only 
> returns the recorded value if the according mode is not smaller than the 
> mode for which get_last_value is called.
> 
> Segher already tested the patch on 32 different (sub-)architectures of 
> Linux without any regression, cf.
> 
> https://gcc.gnu.org/ml/gcc/2016-07/msg00215.html
> 
> Ok for trunk and to backport?

Okay for trunk, okay for backport after a week or so.

Thanks!


Segher
diff mbox

Patch

Index: combine.c
===================================================================
--- combine.c	(revision 238849)
+++ combine.c	(working copy)
@@ -13210,6 +13210,12 @@  get_last_value (const_rtx x)
       && DF_INSN_LUID (rsp->last_set) >= subst_low_luid)
     return 0;
 
+  /* If fewer bits were set than what we are asked for now, we cannot use
+     the value.  */
+  if (GET_MODE_PRECISION (rsp->last_set_mode)
+      < GET_MODE_PRECISION (GET_MODE (x)))
+    return 0;
+
   /* If the value has all its registers valid, return it.  */
   if (get_last_value_validate (&value, rsp->last_set, rsp->last_set_label, 0))
     return value;