[all-commits] [llvm/llvm-project] 4eba5b: [DAGCombiner] Require a 0/1 carry-in when rebuildi...

Paweł Bylica via All-commits all-commits at lists.llvm.org
Mon Sep 14 08:38:38 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4eba5bce282ded21bb912b22aae4aa91e27818da
      https://github.com/llvm/llvm-project/commit/4eba5bce282ded21bb912b22aae4aa91e27818da
  Author: Paweł Bylica <pawel at hepcolgum.band>
  Date:   2026-09-14 (Mon, 14 Sep 2026)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/test/CodeGen/AArch64/cgp-usubo.ll
    M llvm/test/CodeGen/X86/subcarry.ll

  Log Message:
  -----------
  [DAGCombiner] Require a 0/1 carry-in when rebuilding a borrow chain (#223396)

combineOrOfSetCCToUSUBOCarry (aae871ba1224) rewrites

  carry_out = (A <u B) | ((A == B) & carry_in)

to USUBO_CARRY(A, B, carry_in), accepting any value as carry_in.

USUBO_CARRY's third operand is specified as "1 if and only if there is
an incoming carry/borrow", so 0 and 1 are its only meaningful values.
Unlike SADDO_CARRY/SSUBO_CARRY it does not fall back to
getBooleanContents for wider types. The matched `and` is bitwise against
a 0/1 setcc, so only bit 0 of carry_in reaches carry_out and nothing
else constrains it; a carry_in with any other bit set is outside the
operand's contract and miscompiles.

Require carry_in to be known 0/1. Check known bits rather than look for
an `and carry_in, 1`: only bit 0 is demanded inside the `and`, so such a
mask is usually folded away before this combine runs. An i1 carry_in,
which is what a real borrow chain produces, passes trivially.

Fixes #222839.

Assisted-by: Claude Code



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