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] |
The problem here is that we get in fold the following expression: 0 == 0 ? 0 : 1 We go into an infinite calling fold over and over again.
There are a couple of ways fixing this: 1. Call fold on arg0 when we have a COND_EXPR. 2. Make sure that fold does not go into an infinite loop. 3. fold the EQ_EXPR before getting into fold.
The problem with 3, is that in DOM, we replace, a with 0 where the original expression was "a == 0 ? 0 : 1" so DOM is just replacing an expression with its value and should not be the one who is folding the expression.
The problem with 2, is the code would just get too complex and less readable.
So I went with number 1 which was also the easiest of them all.
Thanks, Andrew Pinski
ChangeLog: * fold-const.c (fold_ternary) <case COND_EXPR>: Fold arg0 before doing anything else.
Attachment:
t46.diff.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |