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]

[PR71408] - Fix wrong code at -Os and above


Hi All,

For the testcase in PR71408 zero_one_operation seems still broken. In handling NEGATE_EXPR, as part of undistribute_ops_list, in zero_one_operation, we are doing propagate_op_to_single_use (op, stmt, def);

This results in:
-  _14 = _5 * _12;
   _15 = (int) _11;
   _16 = ~_15;
   _17 = (unsigned int) _16;
-  _18 = -_5;
-  _19 = _17 * _18;
-  _20 = _14 + _19;
-  _24 = _5 & _20;
+  _19 = _5 * _17;
+  _35 = _19 + _12;
+  _34 = _35 * _5;
+  _20 = _34;
+  _24 = _20 & _5;

We should instead propagate (-1) as "op" is the one which gets factored out. With the attached patch we now have:
-  _14 = _5 * _12;
   _15 = (int) _11;
   _16 = ~_15;
   _17 = (unsigned int) _16;
-  _18 = -_5;
-  _19 = _17 * _18;
-  _20 = _14 + _19;
-  _24 = _5 & _20;
+  _32 = _17;
+  _19 = -_32;
+  _34 = _19 + _12;
+  _33 = _34 * _5;
+  _20 = _33;
+  _24 = _20 & _5;

Regression tested and bootstrapped on x86-64-linux-gnu with no new regression. Is this OK for trunk?

Thanks,
Kugan

gcc/ChangeLog:

2016-06-05  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR middle-end/71408
	* tree-ssa-reassoc.c (zero_one_operation): Fix NEGATE_EXPR operand for
	propagate_op_to_single_use.


gcc/testsuite/ChangeLog:

2016-06-05  Kugan Vivekanandarajah  <kuganv@linaro.org>

	PR middle-end/71408
	* gcc.dg/tree-ssa/pr71408.c: New test.



Attachment: pr71408.txt
Description: Text document


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