[llvm] Adding abdu/abds to canCreateUndefOrPoison (PR #149017)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 01:17:33 PDT 2025


RKSimon wrote:

Thanks AnnuCode - for the alive2 tests you can test with the generic pattern, although you need to account for the final truncation as well for completeness:
```ll
define i4 @src(i4 %x, i4 %y) {
entry:
  %a   = zext   i4 %x to i8
  %b   = zext   i4 %y to i8
  %d   = sub    i8 %a, %b
  %t   = call   i8 @llvm.abs.i8(i8 %d, i1 false)
  %r   = trunc i8 %t to i4
  %f   = freeze i4 %r
  ret  i4 %f
}

define i4 @tgt(i4 %x, i4 %y) {
entry:
  %fx  = freeze i4 %x
  %fy  = freeze i4 %y
  %a1  = zext   i4 %fx to i8
  %b1  = zext   i4 %fy to i8
  %d1  = sub    i8 %a1, %b1
  %t1  = call   i8 @llvm.abs.i8(i8 %d1, i1 false)
  %r1  = trunc i8 %t1 to i4
  ret  i4 %r1
}
```

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


More information about the llvm-commits mailing list