[PATCH] D133362: [InstCombine] Fold x + (x | -x) to x & (x - 1)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 6 12:06:31 PDT 2022
spatel added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1425-1428
+ // (add A (or A, -A)) --> (and (add A, -1) A)
+ // (add A (or -A, A)) --> (and (add A, -1) A)
+ // (add (or A, -A) A) --> (and (add A, -1) A)
+ // (add (or -A, A) A) --> (and (add A, -1) A)
----------------
This shows the expected set of commuted variants of the general pattern, but I don't think the match is handling all of them.
You'll want to add tests for each of these variations, and that's going to require some bonus instructions to make the patterns stick until we reach this point in visitAdd().
Here are some tests that I recently added that can serve as templates - note especially the lines with "thwart complexity-based canoinicalization":
d4a4004c0f9d3070
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133362/new/
https://reviews.llvm.org/D133362
More information about the llvm-commits
mailing list