[llvm-commits] [llvm] r139263 - /llvm/trunk/lib/Target/README.txt

Benjamin Kramer benny.kra at googlemail.com
Thu Sep 8 10:37:07 PDT 2011


On Thu, Sep 8, 2011 at 05:53, Marius Wachtler <undingen at gmail.com> wrote:
> Hello
>
> I am trying to implement this as an exercise for me.
> Attached you can find a patch which should implement the first
> transformation as an InstructionSimplify optimization.
>
> Can you please give me feedback if I'm on the right track to do this
> in InstSimplify and using the matcher?
> My pattern looks complicated and very specific is there a easy/better
> way to do it?

These patterns are fine, but indeed very specific. I think there is a
more general way to do this. What I had in mind (maybe Duncan's idea
is different and he knows InstSimplify a lot better than me), is to
substitute the value from the equality comparison into the expression
on the other side and see if it evaluates to true.

(A == 0) | ((A & ?) == 0) -> (A == 0) | ((0 & ?) == 0) -> (A == 0) | true
Now we know that the first expression is redundant and we can drop it.
We can use the same trick for & with != and false.

We have similar code in InstCombineSelect.cpp (look for
SimplifyWithOpReplaced). To get this kind of cases it has to be
enhanced to do the substitution on multiple levels though, I don't
know how hard that is with the current InstSimplify machinery.

- Ben



More information about the llvm-commits mailing list