[LLVMdev] Simplifying selects + arm stuff

Duncan Sands baldrick at free.fr
Thu Nov 11 08:30:56 PST 2010


Hi Chris,

> Instead of turning this into a phase ordering issue, I'd rather increase the power of the folding logic to catch the general form.  In this case, instead of handling this in instsimplify, why not handle this in reassociate?
>
> This is conceptually no different than (x&  y&  x) ->  (x&  y), it's just that in this case you have: (x&  y&  (x or -1)) which should fold to (x&  y) just the same.

in fact this already works, at least for the given example:
  -instcombine -reassociate -instcombine results in:

original:
   %z = and i32 %x, %y
   %s = select i1 %cond, i32 %y, i32 %z
   %r = and i32 %x, %s

after first instcombine:
   %z = select i1 %cond, i32 -1, i32 %x
   %s = and i32 %z, %y
   %r = and i32 %s, %x

after reassociate:
   %z = select i1 %cond, i32 -1, i32 %x
   %s = and i32 %y, %x
   %r = and i32 %s, %z

after second instcombine:
   %s = and i32 %y, %x

This might be a coincidence, but I am happy for the moment :)

Ciao,

Duncan.



More information about the llvm-dev mailing list