I hit a problem about the 2 operands of a addr-plus instruction. My instruction is special because it is not commutative and requries address be the 2nd operand and the offset in the 3rd one. But my port generates PLUS_EXPR instead of POINTER_PLUS_EXPR and finally mistakenly switches the order of the address and offset. The relevant code is in fold-const.c: 10281 switch (code) 10282 { 10283 case POINTER_PLUS_EXPR: .... 10292 /* INT +p INT -> (PTR)(INT + INT). Stripping types allows for this. */ 10293 if (INTEGRAL_TYPE_P (TREE_TYPE (arg1)) 10294 && INTEGRAL_TYPE_P (TREE_TYPE (arg0))) 10295 return fold_convert_loc (loc, type, 10296 fold_build2_loc (loc, PLUS_EXPR, uintptrtype, 10297 fold_convert_loc (loc, uintptrtype, 10298 arg1), 10299 fold_convert_loc (loc, uintptrtype, 10300 arg0)));
the code seems to force gcc to generate a PLUS_EXPR instead of POINTER_PLUS_EXPR and I am not clear what is the context for the piece of code. The code was checked in by Andrew in 2007 (http://gcc.gnu.org/ml/fortran/2007-06/msg00163.html) Could anybody kindly explain me what was going on with that piece of code? or more specifically: 1. what does INT +p INT mean? shouldn't POINTER_PLUS_EXPR always better than PLUS_EXPR? why change to PLUS_EXPR? 2. In general, when we should use POINTER_PLUS_EXPR and PLUS_EXPR. I understand the good of POINTER_PLUS_EXPR in my case. but it seems that it is not strictly enforced that address+offset should always represented by POINTER_PLUS_EXPR . Then can anybody tell me what the rule that a POINTER_PLUS_EXPR should be or happens to be used? Another irlevant question is where I can find the regression test result of the gcc releases such as 4.5/4.7? I try to find out which dejagnu tests have known-failures. thanks