[llvm] [GISel][CombinerHelper] Combine and(trunc(x), trunc(y)) -> trunc(and(x, y)) (PR #89023)
Dhruv Chawla via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 17 06:19:51 PDT 2024
dc03-work wrote:
> > > Should move this to tablegen patterns
> >
> >
> > @arsenm Which file would this be? I had tried searching for something like this originally but couldn't find anything.
>
> https://llvm.org/docs/GlobalISel/MIRPatterns.html
>
> It would go in the generic Combine.td, just with most of the C++ boilerplate replaced with tablegen
Hmm, one of the issues is that we need to match the types as well (the types of x and y in trunc(x) and trunc(y) need to be the same) so that the and(x, y) is well formed. I am not sure if this is possible through TableGen.
I am considering moving the code into https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp#L2960, which is where the folds for `logic (hand x, ...), (hand y, ...) -> hand (logic x, y), ...` currently live. I think this patch fits in quite neatly there, and the logic for matching is already written.
https://github.com/llvm/llvm-project/pull/89023
More information about the llvm-commits
mailing list