[tree-ssa] tree-ssa-dom.c: Fix PR 14303.

Kazu Hirata kazu@cs.umass.edu
Thu Mar 11 19:36:00 GMT 2004


Hi Jeff,

> real_compare (GE_EXPR, TREE_REAL_CST (op1), dconst0)

You meant LE_EXPR, I think.

>  > One thing I am worried about is that no part of tree-ssa-dom.c has an
>  > expression transformation as bold as my patch.
> I'm not exactly sure what you mean by that.  

I meant that most (some?) parts of tree-ssa-dom.c create a dummy tree
node call fold, whereas my patch explicitly transforms an expression
on site.

>  > Should I build a dummy tree node and have fold() fold it?
> That should not be necessary.

OK.

Tested on h8300-elf.  OK to apply?

Kazu Hirata

2004-03-11  Kazu Hirata  <kazu@cs.umass.edu>

	PR optimization/14303
	* tree-ssa-dom.c (simplify_cond_and_lookup_avail_expr): Fold
	abs (x) < (positive real value) into false.

2004-03-11  Kazu Hirata  <kazu@cs.umass.edu>

	PR optimization/14303
	* gcc.c-torture/execute/20020720-1.x: Remove.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.146
diff -u -r1.1.2.146 tree-ssa-dom.c
--- tree-ssa-dom.c	8 Mar 2004 02:07:31 -0000	1.1.2.146
+++ tree-ssa-dom.c	11 Mar 2004 03:39:32 -0000
@@ -1959,6 +1959,19 @@
 		}
 	    }
 
+	  /* abs (x) < CST is always false if CST is less than or
+	     equal to 0.0.  */
+	  if (TREE_CODE (cond) == LT_EXPR
+	      && TREE_CODE (op1) == REAL_CST
+	      && real_compare (LE_EXPR, &TREE_REAL_CST (op1), &dconst0))
+	    {
+	      tree def = SSA_NAME_DEF_STMT (op0);
+
+	      if (TREE_CODE (def) == MODIFY_EXPR
+		  && TREE_CODE (TREE_OPERAND (def, 1)) == ABS_EXPR)
+		return boolean_false_node;
+	    }
+
 	  /* Consult the value range records for this variable (if they exist)
 	     to see if we can eliminate or simplify this conditional. 
 
Index: 20020720-1.x
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/20020720-1.x,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 20020720-1.x
--- 20020720-1.x	2 Mar 2004 18:43:20 -0000	1.1.2.9
+++ 20020720-1.x	11 Mar 2004 19:24:52 -0000
@@ -1,38 +0,0 @@
-# The following targets fail 20020720-1.c for several reasons:
-# (1) They implement floating point instructions via software, or
-# (2) The "abs(x) < 0.0" comparison is split up in too many intermediate
-#     insns for combine to handle -- it can handle max three insns
-#     simultaneously.  For example, for RISCy machines it is common that 1
-#     insn performs abs, 1 insn loads 0.0, 1 insn sets CCmode flags based
-#     upon the FP comparison, and a 4th insn makes a conditional branch
-#     based upon the appropriate bits in the flags.  On the other hand, if
-#     for example the comparison insn takes 0.0 as an operand, the
-#     combiner is able to see all intermediate instructions simultaneously
-#     and can make the optimization.
-
-# Don't XFAIL at -O0, that should never fail.
-if { [istarget "sparc*-*-*"] } {
-    set torture_eval_before_compile {
-        global compiler_conditional_xfail_data
-        set compiler_conditional_xfail_data {
-            "PR opt/10348" \
-            { "*-*-*" } \
-            { "-fpic" "-fPIC" } \
-            { "-O0" }
-        }
-    }
-    return 0
-}
-
-set torture_eval_before_compile {
-    global compiler_conditional_xfail_data
-    set compiler_conditional_xfail_data {
-        "This test fails to optimize completely on certain platforms." \
-        { "xtensa-*-*" "sh-*-*" "arm*-*-*" "strongarm*-*-*" "xscale*-*-*" \
-	  "h8300*-*-*" "cris-*-*" "frv-*-*" } \
-        { "*" } \
-        { "-O0" }
-    }
-}
-
-return 0



More information about the Gcc-patches mailing list