On Fri, 6 Mar 2009, Richard Guenther wrote: > Well, I was thinking about detecting the pattern on the tree level instead. > > s_6 = x.0_2 + y.1_4; > D.1597_7 = s_6 ^ x_1(D); > D.1598_8 = s_6 ^ y_3(D); > D.1599_9 = D.1597_7 & D.1598_8; > if (D.1599_9 < 0) > goto <bb 3>; > else > goto <bb 4>; > > <bb 3>: > __builtin_trap (); > > <bb 4>: > > This should be recognizable in the ifcombine pass for example, which > recognizes CFG patterns. Transforming it to just > > s_6 = __builtin_addv (x.0_2, y.1_4); > > <bb 4>: > > Only ifcombine runs a little too early for that maybe.
In addition to detecting to transform into something like the above (for addv insn patterns or libgcc function), you may also want to detect when a constant has been propagated into the above and make sure it can get optimized into a range check on the non-constant operand. (I don't know if existing optimizers will be able to handle the above with a constant for one of the operands and convert it to a range check, or whether special code would be needed.) -- Joseph S. Myers jos...@codesourcery.com