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] |

*From*: Tom de Vries <Tom_deVries at mentor dot com>*To*: Jeff Law <law at redhat dot com>*Cc*: GCC Patches <gcc-patches at gcc dot gnu dot org>*Date*: Wed, 30 Aug 2017 08:25:58 +0200*Subject*: Re: [PATCH] Fix bug in simplify_ternary_operation*Authentication-results*: sourceware.org; auth=none*References*: <82ea4bb9-15cb-b00d-c6af-e1de926a9cec@mentor.com>

On 08/28/2017 08:26 PM, Tom de Vries wrote:

Hi, I think I found a bug in r17465: ...* cse.c (simplify_ternary_operation): Handle more IF_THEN_ELSE simplifications. diff --git a/gcc/cse.c b/gcc/cse.c index e001597..3c27387 100644 --- a/gcc/cse.c +++ b/gcc/cse.c@@ -4713,6 +4713,17 @@ simplify_ternary_operation (code, mode,op0_mode, op0, op1, op2)Note: the parameters of simplify_ternary_operation have the followingmeaning:... /* Simplify CODE, an operation with result mode MODE and three operands, OP0, OP1, and OP2. OP0_MODE was the mode of OP0 before it became a constant. Return 0 if no simplifications is possible. */ rtx simplify_ternary_operation (code, mode, op0_mode, op0, op1, op2) enum rtx_code code; enum machine_mode mode, op0_mode; rtx op0, op1, op2; ...&& rtx_equal_p (XEXP (op0, 1), op1) && rtx_equal_p (XEXP (op0, 0), op2)) return op2; + else if (! side_effects_p (op0)) + { + rtx temp; + temp = simplify_relational_operation (GET_CODE (op0), op0_mode,+ XEXP (op0, 0), XEXP(op0, 1));We're handling code == IF_THEN_ELSE here, so op0 is the condition, op1is the 'then expr' and op2 is the 'else expr'.The parameters of simplify_relational_operation have the following meaning: ... /* Like simplify_binary_operation except used for relational operators. MODE is the mode of the operands, not that of the result. If MODE is VOIDmode, both operands must also be VOIDmode and we compare the operands in "infinite precision". If no simplification is possible, this function returns zero. Otherwise, it returns either const_true_rtx or const0_rtx. */ rtx simplify_relational_operation (code, mode, op0, op1) enum rtx_code code; enum machine_mode mode; rtx op0, op1; ...The problem in the patch is that we use op0_mode argument for the modeparameter. The mode parameter of simplify_relational_operation needs tobe the mode of the operands of the condition, while op0_mode is the modeof the condition.Patch below fixes this on current trunk.[ I found this by running into an ICE ingcc.c-torture/compile/pr28776-2.c for gcn target. I haven't been able toreproduce this with an upstream branch yet. ]

OK for trunk if bootstrap and reg-test for x86_64 succeeds?

bootstrap and reg-test for x86_64 done, no issues found. Thanks, - Tom [ reposting patch with ChangeLog entry ]

Fix comparison mode in simplify_ternary_operation 2017-08-29 Tom de Vries <tom@codesourcery.com> PR rtl-optimization/82020 * simplify-rtx.c (simplify_ternary_operation): Fix comparison mode of IF_THEN_ELSE condition. --- gcc/simplify-rtx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 0133d43..fbf979b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -5567,8 +5567,6 @@ simplify_ternary_operation (enum rtx_code code, machine_mode mode, XEXP (op0, 0), XEXP (op0, 1)); } - if (cmp_mode == VOIDmode) - cmp_mode = op0_mode; temp = simplify_relational_operation (GET_CODE (op0), op0_mode, cmp_mode, XEXP (op0, 0), XEXP (op0, 1));

**References**:**[PATCH] Fix bug in simplify_ternary_operation***From:*Tom de Vries

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |