[PATCH] D35182: [InstCombine] remove one-use restriction for not (cmp P, A, B) --> cmp P', A, B

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 04:39:51 PDT 2017


spatel added a comment.

In https://reviews.llvm.org/D35182#828396, @craig.topper wrote:

> The C code with the global variables never creates a 'not' operation and never combines the 4 compares with 0. For your modified version, it looks like something combined the two compares with A into a single compare and the xor and with this patch instcombine undoes that. Isn't that moving in the opposite direction of PR27431?


Yes,  you're correct - the 'not' isn't in the version with the globals for some reason. But the end result is similar - we fail to recognize the DeMorgan equivalents.

And yes, this is going in the other direction from the suggestion in PR27431. There are 3 options as I see it:

1. We standardize instcombine to always transform not(cmp) to the inverted predicate (this patch); we enhance GVN or other passes to recognize DeMorgan patterns (which we may want to do first and anyway).
2. We standardize instcombine to not transform not(cmp) and enhance its pattern matching to account for the extra 'not' ops.
3. We live with the current instcombine behavior (not(cmp) is transformed with only 1-use), and add folds like https://reviews.llvm.org/D32725. That patch alone isn't enough to catch the PR27431 example with globals, is it?


https://reviews.llvm.org/D35182





More information about the llvm-commits mailing list