[PATCH] D109729: [RISCV] Optimize (add (shl x, c0), (shl y, c1))
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 13 16:52:18 PDT 2021
craig.topper added a comment.
In D109729#2998734 <https://reviews.llvm.org/D109729#2998734>, @craig.topper wrote:
> In D109729#2998731 <https://reviews.llvm.org/D109729#2998731>, @benshi001 wrote:
>
>> The reason I write both AddShlShl_1A and def AddShlShl_1B, is that add is not commutative in PatFrag.
>
> You should write that as a comment in the code.
Actually it's worse than that. Tablegen does know the pattern is commutable and will call you predicate function twice. But one of the calls will be wrong. I hope it is guaranteed that the correct check always happens first. There is a feature to make this work. It involves setting "let PredicateCodeUsesOperands = 1;" on the PatFrag. Only AMDGPU uses it. You should look up the patch that added it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109729/new/
https://reviews.llvm.org/D109729
More information about the llvm-commits
mailing list