This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR66211


The following papers over the C++ FE issue that it doesn't track
lvalueness before folding stuff.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2015-05-21  Richard Biener  <rguenther@suse.de>

	PR c++/66211
	* match.pd: Guard pattern optimzing (int)(float)int
	conversions to apply only on GIMPLE.

	* g++.dg/conversion/pr66211.C: New testcase.
	* gcc.dg/tree-ssa/forwprop-18.c: Adjust.

Index: gcc/testsuite/g++.dg/conversion/pr66211.C
===================================================================
*** gcc/testsuite/g++.dg/conversion/pr66211.C	(revision 0)
--- gcc/testsuite/g++.dg/conversion/pr66211.C	(working copy)
***************
*** 0 ****
--- 1,11 ----
+ // PR c++/66211
+ // { dg-do compile }
+ 
+ void f(int&){}
+ 
+ int main()
+ {
+   int x = 0;
+   double y = 1;
+   f(1 > 0 ? x : y); // { dg-error "from an rvalue" }
+ }
Index: gcc/match.pd
===================================================================
--- gcc/match.pd	(revision 223348)
+++ gcc/match.pd	(working copy)
@@ -791,7 +791,8 @@ (define_operator_list inverted_tcc_compa
    /* If we are converting an integer to a floating-point that can
       represent it exactly and back to an integer, we can skip the
       floating-point conversion.  */
-   (if (inside_int && inter_float && final_int &&
+   (if (GIMPLE /* PR66211 */
+	&& inside_int && inter_float && final_int &&
 	(unsigned) significand_size (TYPE_MODE (inter_type))
 	>= inside_prec - !inside_unsignedp)
     (convert @0))))))
Index: gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c	(revision 223348)
+++ gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-forwprop1" } */
+/* { dg-options "-O -fdump-tree-cddce1" } */
 
 signed char f1(signed char n)
 {
@@ -19,6 +19,6 @@ signed char g2(unsigned long long n)
   return (float)n;
 }
 
-/* { dg-final { scan-tree-dump-times "\\\(float\\\)" 2 "forwprop1" } } */
-/* { dg-final { scan-tree-dump-not "\\\(long double\\\)" "forwprop1" } } */
-/* { dg-final { cleanup-tree-dump "forwprop1" } } */
+/* { dg-final { scan-tree-dump-times "\\\(float\\\)" 2 "cddce1" } } */
+/* { dg-final { scan-tree-dump-not "\\\(long double\\\)" "cddce1" } } */
+/* { dg-final { cleanup-tree-dump "cddce1" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]