LLVM recently added two families of intrinsics named llvm.scmp.* and llvm.ucmp.* that generate potentially better code for three-way comparison operations. This PR lowers certain cir.cmp3way operations to these intrinsics.
Not all cir.cmp3way operations can be lowered to these intrinsics. The qualifying conditions are: 1) the comparison is between two integers, and 2) the comparison produces a strong ordering. cir.cmp3way operations that are not qualified are not affected by this PR.
Qualifying cir.cmp3way operations may still need some canonicalization work before lowering. The "canonicalized" form of a qualifying three-way comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR converts those non-canonicalized but qualifying cir.cmp3way operations to their canonical forms in the LLVM lowering prepare pass.
LLVM recently added two families of intrinsics named
llvm.scmp.*
andllvm.ucmp.*
that generate potentially better code for three-way comparison operations. This PR lowers certaincir.cmp3way
operations to these intrinsics.Not all
cir.cmp3way
operations can be lowered to these intrinsics. The qualifying conditions are: 1) the comparison is between two integers, and 2) the comparison produces a strong ordering.cir.cmp3way
operations that are not qualified are not affected by this PR.Qualifying
cir.cmp3way
operations may still need some canonicalization work before lowering. The "canonicalized" form of a qualifying three-way comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR converts those non-canonicalized but qualifyingcir.cmp3way
operations to their canonical forms in the LLVM lowering prepare pass.This PR addresses #514 .