[llvm-dev] IR canonicalization: select or bool math?
Chris Lattner via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 28 21:21:15 PDT 2016
> On Sep 28, 2016, at 5:41 PM, Hal Finkel via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I have another round of questions about IR select canonicalizations. For the purity of this quiz, please disregard prior knowledge of how this is handled by instcombine or how this is lowered by your favorite target...of course we'll fix it. :) Some answers in the links below if you do want to know.
> Which, if any, of these is canonical?
> I think that we should prefer the single-IR-instruction forms as canonical. zext/sext, when it is all that is needed, and the select otherwise. I suspect that will be better for analysis and follow-on optimizations, at least most of the time. For lowering, OTOH, I'd prefer the forms with zext/sext combined with xor/add/sub.
Right. That’s the general (abstract, and probably not uniformly followed) goal: canonicalize towards the conceptually most strength reduced operation. zext is simpler than select, so it should be more canonical when it applies.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev