[llvm] [GISel][RISCV] Use isSExtCheaperThanZExt when widening G_ICMP. (PR #120032)

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 21:48:39 PST 2024


aemerson wrote:

> > > Curious: why is it correct to do a sign-extend for an unsigned comparison promotion?
> > 
> > 
> > eq / ne / true / false aren't really signed or unsigned, you just need to treat the high bits consistently in both operands
> 
> This isn't limited eq / ne / true / false. It works for ugt/uge/ult/ule too.
> 
> Sign extending an unsigned value doesn't change 0x00000000-0x7ffffff and it makes 0x8000000-0xffffffff into even larger numbers without affecting their relative order.

Makes sense.

https://github.com/llvm/llvm-project/pull/120032


More information about the llvm-commits mailing list