Andrew Pinski wrote: > Hi, > After SSA-expand, the code which did the optimization for > (a&(1<<C))!=0 to (a>>C)&1 became not working because BIT_AND_EXPR > would no longer be in there. This patch fixes the problem by using > get_def_for_expr to get the BIT_AND_EXPR. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
No, not OK. This leads to unacceptable code for devices that cannot shift easily like, e.g. AVR. This target can only shift by 1 and shifts with big offsets have to be performed by means of a loop at runtime. Instead of a single bit-test instruction than can test for a bit in place, the patch leads to very expensive shift! Please try code examples compiled for that target against the code form 4.6! Such transformation must not be performed unconditionally and not without looking at costs. Johann > Thanks, > Andrew Pinski > > ChangeLog: > * expr.c (do_store_flag): Rewrite code that looks for BIT_AND_EXPR for > SSA-expand. > > testsuite/ChangeLog: > * gcc.dg/pr45416.c: New testcase.