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] |
Hi. The attached patch adds new match-and-simplify patterns, which fold ~((~a) >> b) into (a >> b) for arithmetic shifts (i.e. when A is signed) and perform similar folds for rotations. It also fixes PR tree-optimization/54579 (because we already fold (-a - 1) into ~a). A couple of questions: 1. Should we limit folding to this special case or rather introduce some canonical order of bitnot and shifts (when they are commutative)? In the latter case, which order is better: bitnot as shift/rotate operand or vise-versa? 2. I noticed that some rotation patterns are folded on tree, while other are folded rather late (during second forward propagation). For example on LP64: #define INT_BITS (sizeof (int) * 8) unsigned int rol(unsigned int a, unsigned int b) { return a << b | a >> (INT_BITS - b); } INT_BITS has type unsigned long, so b and (INT_BITS - b) have different types and tree folding fails (if I change int to long, everything is OK). Should this be addressed somehow? 3. Do the new patterns require any special handling of nop-conversions? -- Regards, Mikhail Maltsev
Attachment:
fold_asr.clog
Description: Text document
Attachment:
fold_asr.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |