[llvm-dev] IR canonicalization: select or bool math?

Krzysztof Parzyszek via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 29 09:12:25 PDT 2016


On 9/28/2016 11:21 PM, Chris Lattner via llvm-dev wrote:
> 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.

IMO, canonicalization should aim at making it easy for the rest of the 
compiler to reason about the code. While select may not appear the 
simplest in terms of code complexity, it can lead to a simpler code when 
combined with other operations (as per Sanjoy's example), while at the 
same time it can always become a zext later on (if it's not combined 
with anything).

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation


More information about the llvm-dev mailing list