[llvm] [SDAG][abd] Remove duplicate legality check (PR #181538)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 05:17:50 PST 2026


natanelh-mobileye wrote:

the regressions only happen in the tests that involve (as expected) `abd(i128)`.
what happens is this patch allows generating `(sub 0, (abd x, y))` which is illegal, which then might be hard to optimize once legalized:
```
Type-legalized selection DAG: %bb.0 'abd_cmp_i128:'
SelectionDAG has 25 nodes:
  t0: ch,glue = EntryToken
  t2: i64,ch = CopyFromReg t0, Register:i64 %0
  t4: i64,ch = CopyFromReg t0, Register:i64 %1
  t6: i64,ch = CopyFromReg t0, Register:i64 %2
  t8: i64,ch = CopyFromReg t0, Register:i64 %3
  t21: ch,glue = CopyToReg t0, Register:i64 $x0, t37
        t42: i64,i32 = usubo_carry t4, t8, t41:1
        t40: i64,i32 = usubo_carry t8, t4, t39:1
      t49: i64 = select t47, t42, t40
    t38: i64,i32 = usubo_carry Constant:i64<0>, t49, t37:1
  t23: ch,glue = CopyToReg t21, Register:i64 $x1, t38, t21:1
    t48: i64 = select t47, t41, t39
  t37: i64,i32 = usubo Constant:i64<0>, t48
  t39: i64,i32 = usubo t6, t2
  t41: i64,i32 = usubo t2, t6
  t47: i32 = setcccarry t8, t4, t39:1, setlt:ch
  t24: ch = AArch64ISD::RET_GLUE t23, Register:i64 $x0, Register:i64 $x1, t23:1
```
not sure how to optimize it back to more efficient form (where we swap operands of `sub`) but the positive changes appear to suggest that it is worth pursuing.

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


More information about the llvm-commits mailing list