[llvm] [PatternMatch] Do not accept undef elements in m_AllOnes() and friends (PR #88217)

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 04:23:56 PDT 2024


nunoplopes wrote:

Alive2 is complaining about one case (only!):
```llvm
; Transforms/InstCombine/integer-round-up-pow2-alignment.ll

define <2 x i4> @t18_replacement_0b0001(<2 x i4> %x) {
  %x.lowbits = and <2 x i4> %x, { 3, 3 }
  %x.lowbits.are.zero = icmp eq <2 x i4> %x.lowbits, { 0, 0 }
  %x.biased = add <2 x i4> %x, { 3, 3 }
  %x.biased.highbits = and <2 x i4> %x.biased, { 12, poison }
  call void @use.v2i4(<2 x i4> %x.biased.highbits)
  %x.roundedup = select <2 x i1> %x.lowbits.are.zero, <2 x i4> %x, <2 x i4> %x.biased.highbits
  ret <2 x i4> %x.roundedup
}
=>
define <2 x i4> @t18_replacement_0b0001(<2 x i4> %x) {
  %x.biased = add <2 x i4> %x, { 3, 3 }
  %x.biased.highbits = and <2 x i4> %x.biased, { 12, poison }
  call void @use.v2i4(<2 x i4> %x.biased.highbits)
  ret <2 x i4> %x.biased.highbits
}
Transformation doesn't verify! (unsound)
ERROR: Target is more poisonous than source

Example:
<2 x i4> %x = < #x0 (0), #x0 (0) >

Source:
<2 x i4> %x.lowbits = < #x0 (0), #x0 (0) >
<2 x i1> %x.lowbits.are.zero = < #x1 (1), #x1 (1) >
<2 x i4> %x.biased = < #x3 (3), #x3 (3) >
<2 x i4> %x.biased.highbits = < #x0 (0), poison >
Function @use.v2i4 returned
<2 x i4> %x.roundedup = < #x0 (0), #x0 (0) >

Target:
<2 x i4> %x.biased = < #x3 (3), #x3 (3) >
<2 x i4> %x.biased.highbits = < #x0 (0), poison >
Function @use.v2i4 returned
Source value: < #x0 (0), #x0 (0) >
Target value: < #x0 (0), poison >
```

Several tests got fixed btw! 🙏

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


More information about the llvm-commits mailing list