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 416.gamess miscompare (PR71311)


The following patch adds missing patterns with swapped comparison
operands for the @0 < @1 and @0 < @2 to @0 < min (@1, @2) transform.
This nullifies the difference gimplify-into-SSA made on
rhfuhf.F:ROFOCK which causes the function no longer to be miscompiled
(by vectorization eventually, -fno-tree-vectorize also fixes the
miscompare at r235817).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

I didn't attempt to understand the miscompile or create an executable
testcase.

Richard.

2016-05-31  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/71311
	* match.pd (@0 < @1 and @0 < @2 to @0 < min (@1, @2)): Add
	cases with swapped comparison operands.

Index: gcc/match.pd
===================================================================
--- gcc/match.pd	(revision 235817)
+++ gcc/match.pd	(working copy)
@@ -3179,6 +3179,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (bit_and (op:s @0 @1) (op:s @0 @2))
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)))
    (op @0 (ext @1 @2)))))
+/* Transform (@1 < @0 and @2 < @0) to use max,
+   (@1 > @0 and @2 > @0) to use min */
+(for op (lt le gt ge)
+     ext (max max min min)
+ (simplify
+  (bit_and (op:s @1 @0) (op:s @2 @0))
+  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)))
+   (op (ext @1 @2) @0))))
+/* Transform (@0 < @1 and @2 > @0) to use min, 
+   (@0 > @1 and @2 < @0) to use max */
+(for op (lt le gt ge)
+     ops (gt ge lt le)
+     ext (min min max max)
+ (simplify
+  (bit_and:c (op:s @0 @1) (ops:s @2 @0))
+  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)))
+   (op @0 (ext @1 @2)))))
 
 (simplify
  /* signbit(x) -> 0 if x is nonnegative.  */


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