This patch fixes a bug in the vectorized pointer arithmetic in the forwprop optimization pass.
Although it seems to be impossible to create a vector of pointers with the __attribute__((vector_size(x))) syntax, the vector loop optimization together with the loop unrolling can create code which adds a vector of ptroff_t repeatedly to a vector of pointers. The code in tree-ssa-forwprop.c handles program transformations of the form (PTR +- CST1) +- CST2 => PTR +- (CST1+-CST2) where PTR is a vector of pointers and CST1 and CST2 are vectors of ptroff_t, without the fix the result type of CST1+-CST2 was vector of pointer, which causes the ICE in tree-cfg.c, which sees an undefined pointer + pointer operation. Additionally the check in tree-cfg.c allows expressions of the form CST - PTR, which is clearly wrong. That should be fixed too. The patch was bootstrapped and regression tested on i686-pc-linux-gnu. Regards Bernd Edlinger
2013-08-20 Bernd Edlinger <bernd.edlin...@hotmail.de> PR tree-optimization/58137 Fixed vectorized pointer arithmentic in constant folding at forwprop. Improved checks in verify_gimple_in_cfg: MINUS_EXPR with pointer vectors is not commutative. * tree-cfg.c (verify_gimple_assign_binary): Only PLUS_EXPR is commutative. * tree-ssa-forwprop.c (fold_const_type): New function. (associate_plusminus): Fold constant pointer vector types correctly. * gcc.target/i386/pr58137.c: New test.
patch-forwprop.diff
Description: Binary data