[PATCH] D36498: [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt trunc X, 0) and (icmp sgt trunc X, -1) as equivalent to an and with the sign bit of the truncated type

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 10:14:18 PDT 2017


spatel added a comment.

I've been operating under the assumption that we want to transform in the opposite direction in IR. Ie, preserve and probably create more select-of-constants (see https://reviews.llvm.org/D24480 which I am planning to abandon). We should be able to reduce selects to logic/math in the DAG where it makes sense (eg, https://reviews.llvm.org/rL310717 ). Some reasons to prefer select were noted in:
http://lists.llvm.org/pipermail/llvm-dev/2016-September/105335.html

Not sure if it was listed there, but another reason we might actually want to keep a cmp/select in IR is in the case where we have profile info / branch stats. If we know in IR that a cmp always goes one direction, then the target might prefer to turn the select into control flow instead of turning it into logic ops. There's some infrastructure for this in CGP already. See also: https://reviews.llvm.org/D36081


https://reviews.llvm.org/D36498





More information about the llvm-commits mailing list