[all-commits] [llvm/llvm-project] 848dfb: [Hexagon] Do not sign extend the unsigned comparis...

Brian Cain via All-commits all-commits at lists.llvm.org
Thu Aug 6 07:26:28 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 848dfb98225281d68e9682e9eebc658ad7a4ff2c
      https://github.com/llvm/llvm-project/commit/848dfb98225281d68e9682e9eebc658ad7a4ff2c
  Author: Brian Cain <brian.cain at oss.qualcomm.com>
  Date:   2026-08-06 (Thu, 06 Aug 2026)

  Changed paths:
    M llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
    A llvm/test/CodeGen/Hexagon/cmp-extend-unsigned.ll

  Log Message:
  -----------
  [Hexagon] Do not sign extend the unsigned comparison of short integers. (#212914)

HexagonTargetLowering::LowerSETCC widens i8/i16 SETCC operands to i32
with a sign extension when the extension is free, or when the compared
constant is negative in the narrow type. That is what the compare
instructions want for equality comparisons, since they can encode small
negative immediates, but for unsigned comparisons a constant with the
sign bit of the narrow type set becomes a large 32-bit value that has to
be materialized in a register or use a constant extender. For

  %v = load i16, ptr %p
  %c = icmp ult i16 %v, 65524

we generated

  r1 = #-12
  r0 = memh(r0+#0)
  p0 = cmp.gtu(r1,r0)

instead of

  r0 = memuh(r0+#0)
  p0 = cmp.gtu(r0,##65523)

Restrict the transformation to equality condition codes and let the
generic operand promotion pick the extension for everything else. Signed
comparisons are unaffected, as the generic promotion already
sign-extends them.

Note that only the quality of the generated code was affected: sign
extension preserves the unsigned ordering of the values of the narrower
type, so the code produced before this change was correct.

Co-authored-by: Sumanth Gundapaneni <sgundapa at quicinc.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list