<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122430>122430</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [SLPVectorizer] Miscompilation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            llvm:SLPVectorizer,
            generated by fuzzer
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dtcxzyw
      </td>
    </tr>
</table>

<pre>
    Reproducer: https://alive2.llvm.org/ce/z/BopDTn
```
; bin/opt -passes=slp-vectorizer test.ll -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i16 @test(ptr %p1, i16 %inc.143.i76136.lcssa158200.i.i, i16 %inc.1.1.i82139.lcssa160199.i.i, i16 %inc.143.1.i98142.lcssa162198.i.i) {
entry:
  %0 = and i16 %inc.1.1.i82139.lcssa160199.i.i, %inc.143.i76136.lcssa158200.i.i
  %1 = and i16 %0, 0
  %2 = and i16 %1, 0
  %3 = icmp ne i16 %2, 0
  %.not5.not = or i1 %3, false
  %inc.1.1.i82.i.i = or i16 %inc.1.1.i82139.lcssa160199.i.i, 0
  %inc.143.1.i98.i.i = or i16 %inc.143.1.i98142.lcssa162198.i.i, 0
  %4 = or i16 %inc.1.1.i82.i.i, 0
  %5 = or i16 %4, 0
  %6 = or i16 %5, 0
  %7 = icmp ne i16 %6, 0
  %.not7.not = or i1 false, %7
  %8 = or i1 %.not5.not, %.not7.not
  %9 = and i16 %inc.1.1.i82.i.i, 0
  %10 = and i16 0, %inc.143.1.i98.i.i
  %11 = and i16 %10, 0
  %12 = icmp ne i16 %11, 0
 %.not5.not.1 = or i1 %12, false
  %inc.143.i76.i.i.1 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
  %inc.143.1.i98.i.i.1 = or i16 %inc.143.1.i98142.lcssa162198.i.i, 0
  %13 = or i16 0, %inc.143.i76.i.i.1
 %14 = or i16 %13, 0
  %15 = or i16 %14, 0
  %16 = icmp ne i16 %15, 0
 %.not7.not.1 = or i1 false, %16
  %17 = or i1 %.not5.not.1, %.not7.not.1
 %18 = or i1 %8, %17
  %19 = and i16 0, %inc.143.i76.i.i.1
  %20 = and i16 0, %inc.143.1.i98.i.i.1
  %21 = and i16 %20, 0
  %22 = icmp ne i16 %21, 0
 %.not5.not.2 = or i1 %22, false
  %inc.143.i76.i.i.2 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
  %inc.143.1.i98.i.i.2 = or i16 %inc.143.1.i98142.lcssa162198.i.i, 1
  %23 = or i16 0, %inc.143.i76.i.i.2
 %24 = or i16 %23, 0
  %25 = or i16 %24, 0
  %26 = icmp ne i16 %25, 0
 %.not7.not.2 = or i1 false, %26
  %27 = or i1 %.not5.not.2, %.not7.not.2
 %28 = or i1 false, %27
  %29 = and i16 0, %inc.143.i76.i.i.2
  %30 = and i16 0, %inc.143.1.i98.i.i.2
  %31 = and i16 %30, 0
  %32 = icmp ne i16 %31, 0
  %.not5.not.3 = or i1 %32, false
  %inc.143.i76.i.i.3 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
  %33 = or i16 0, %inc.143.i76.i.i.3
 %34 = or i16 %33, 0
  %35 = or i16 %34, 0
  %36 = icmp ne i16 %35, 0
 %.not7.not.3 = or i1 false, %36
  %37 = or i1 %.not5.not.3, %.not7.not.3
 %38 = select i1 %37, i1 true, i1 %27
  %39 = select i1 %38, i1 true, i1 %17
  %40 = select i1 %39, i1 true, i1 %8
  %spec.select31 = select i1 %40, i32 0, i32 0
  %41 = or i1 false, %37
  store i32 %spec.select31, ptr %p1, align 4
  ret i16 %inc.143.i76.i.i.3
}
```
```

----------------------------------------
define i16 @test(ptr %p1, i16 %inc.143.i76136.lcssa158200.i.i, i16 %inc.1.1.i82139.lcssa160199.i.i, i16 %inc.143.1.i98142.lcssa162198.i.i) {
entry:
  %#0 = and i16 %inc.1.1.i82139.lcssa160199.i.i, %inc.143.i76136.lcssa158200.i.i
  %#1 = and i16 %#0, 0
  %#2 = and i16 %#1, 0
  %#3 = icmp ne i16 %#2, 0
  %.not5.not = or i1 %#3, 0
 %inc.1.1.i82.i.i = or i16 %inc.1.1.i82139.lcssa160199.i.i, 0
 %inc.143.1.i98.i.i = or i16 %inc.143.1.i98142.lcssa162198.i.i, 0
  %#4 = or i16 %inc.1.1.i82.i.i, 0
  %#5 = or i16 %#4, 0
  %#6 = or i16 %#5, 0
  %#7 = icmp ne i16 %#6, 0
  %.not7.not = or i1 0, %#7
  %#8 = or i1 %.not5.not, %.not7.not
  %#10 = and i16 0, %inc.143.1.i98.i.i
  %#11 = and i16 %#10, 0
  %#12 = icmp ne i16 %#11, 0
  %.not5.not.1 = or i1 %#12, 0
 %inc.143.i76.i.i.1 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
 %inc.143.1.i98.i.i.1 = or i16 %inc.143.1.i98142.lcssa162198.i.i, 0
  %#13 = or i16 0, %inc.143.i76.i.i.1
  %#14 = or i16 %#13, 0
  %#15 = or i16 %#14, 0
  %#16 = icmp ne i16 %#15, 0
  %.not7.not.1 = or i1 0, %#16
  %#17 = or i1 %.not5.not.1, %.not7.not.1
  %#20 = and i16 0, %inc.143.1.i98.i.i.1
 %#21 = and i16 %#20, 0
  %#22 = icmp ne i16 %#21, 0
  %.not5.not.2 = or i1 %#22, 0
  %inc.143.i76.i.i.2 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
 %inc.143.1.i98.i.i.2 = or i16 %inc.143.1.i98142.lcssa162198.i.i, 1
  %#23 = or i16 0, %inc.143.i76.i.i.2
  %#24 = or i16 %#23, 0
  %#25 = or i16 %#24, 0
  %#26 = icmp ne i16 %#25, 0
  %.not7.not.2 = or i1 0, %#26
  %#27 = or i1 %.not5.not.2, %.not7.not.2
  %#30 = and i16 0, %inc.143.1.i98.i.i.2
 %#31 = and i16 %#30, 0
  %#32 = icmp ne i16 %#31, 0
  %.not5.not.3 = or i1 %#32, 0
  %inc.143.i76.i.i.3 = or i16 %inc.143.i76136.lcssa158200.i.i, 0
 %#33 = or i16 0, %inc.143.i76.i.i.3
  %#34 = or i16 %#33, 0
  %#35 = or i16 %#34, 0
  %#36 = icmp ne i16 %#35, 0
  %.not7.not.3 = or i1 0, %#36
  %#37 = or i1 %.not5.not.3, %.not7.not.3
  %#38 = select i1 %#37, i1 1, i1 %#27
 %#39 = select i1 %#38, i1 1, i1 %#17
  %#40 = select i1 %#39, i1 1, i1 %#8
 %spec.select31 = select i1 %#40, i32 0, i32 0
  store i32 %spec.select31, ptr %p1, align 4
  ret i16 %inc.143.i76.i.i.3
}
=>
define i16 @test(ptr %p1, i16 %inc.143.i76136.lcssa158200.i.i, i16 %inc.1.1.i82139.lcssa160199.i.i, i16 %inc.143.1.i98142.lcssa162198.i.i) {
entry:
  %#0 = insertelement <4 x i16> poison, i16 %inc.143.1.i98142.lcssa162198.i.i, i32 0
  %#1 = insertelement <4 x i16> %#0, i16 %inc.1.1.i82139.lcssa160199.i.i, i32 1
  %#2 = shufflevector <4 x i16> %#1, <4 x i16> poison, 0, 0, 0, 1
  %#3 = insertelement <4 x i16> { 1, 0, 0, poison }, i16 %inc.143.i76136.lcssa158200.i.i, i32 3
  %#4 = or <4 x i16> %#2, %#3
  %#5 = and <4 x i16> %#2, %#3
  %#6 = shufflevector <4 x i16> %#4, <4 x i16> %#5, 0, 1, 2, 7
  %#7 = shufflevector <4 x i16> %#3, <4 x i16> poison, 0, 4294967295
  %#8 = insertelement <2 x i16> %#7, i16 %inc.1.1.i82139.lcssa160199.i.i, i32 1
  %#9 = shufflevector <2 x i16> %#8, <2 x i16> poison, 0, 0, 0, 1
  %#10 = or <4 x i16> %#9, { 0, 0, 0, 0 }
 %#17 = and <4 x i16> %#6, { 0, 0, 0, 0 }
  %#18 = and <4 x i16> %#17, { 0, 0, 0, 0 }
  %#19 = icmp ne <4 x i16> %#18, { 0, 0, 0, 0 }
  %#20 = or <4 x i1> %#19, { 0, 0, 0, 0 }
  %#21 = or <4 x i16> %#10, { 0, 0, 0, 0 }
  %#22 = or <4 x i16> %#21, { 0, 0, 0, 0 }
  %#23 = or <4 x i16> %#22, { 0, 0, 0, 0 }
  %#24 = icmp ne <4 x i16> %#23, { 0, 0, 0, 0 }
  %#25 = or <4 x i1> { 0, 0, 0, 0 }, %#24
  %#26 = or <4 x i1> %#20, %#25
  %#32 = freeze <4 x i1> %#26
  %#33 = reduce_or <4 x i1> %#32
  %spec.select31 = select i1 %#33, i32 0, i32 0
  store i32 %spec.select31, ptr %p1, align 4
  %#36 = extractelement <4 x i16> %#10, i32 0
  ret i16 %#36
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
ptr %p1 = pointer(non-local, block_id=1, offset=0) / Address=#x04
i16 %inc.143.i76136.lcssa158200.i.i = #x0000 (0)
i16 %inc.1.1.i82139.lcssa160199.i.i = poison
i16 %inc.143.1.i98142.lcssa162198.i.i = poison

Source:
i16 %#0 = poison
i16 %#1 = poison
i16 %#2 = poison
i1 %#3 = poison
i1 %.not5.not = poison
i16 %inc.1.1.i82.i.i = poison
i16 %inc.143.1.i98.i.i = poison
i16 %#4 = poison
i16 %#5 = poison
i16 %#6 = poison
i1 %#7 = poison
i1 %.not7.not = poison
i1 %#8 = poison
i16 %#10 = poison
i16 %#11 = poison
i1 %#12 = poison
i1 %.not5.not.1 = poison
i16 %inc.143.i76.i.i.1 = #x0000 (0)
i16 %inc.143.1.i98.i.i.1 = poison
i16 %#13 = #x0000 (0)
i16 %#14 = #x0000 (0)
i16 %#15 = #x0000 (0)
i1 %#16 = #x0 (0)
i1 %.not7.not.1 = #x0 (0)
i1 %#17 = poison
i16 %#20 = poison
i16 %#21 = poison
i1 %#22 = poison
i1 %.not5.not.2 = poison
i16 %inc.143.i76.i.i.2 = #x0000 (0)
i16 %inc.143.1.i98.i.i.2 = poison
i16 %#23 = #x0000 (0)
i16 %#24 = #x0000 (0)
i16 %#25 = #x0000 (0)
i1 %#26 = #x0 (0)
i1 %.not7.not.2 = #x0 (0)
i1 %#27 = poison
i16 %#30 = poison
i16 %#31 = poison
i1 %#32 = poison
i1 %.not5.not.3 = poison
i16 %inc.143.i76.i.i.3 = #x0000 (0)
i16 %#33 = #x0000 (0)
i16 %#34 = #x0000 (0)
i16 %#35 = #x0000 (0)
i1 %#36 = #x0 (0)
i1 %.not7.not.3 = #x0 (0)
i1 %#37 = poison
i1 %#38 = poison
i1 %#39 = poison
i1 %#40 = poison
i32 %spec.select31 = poison

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >    size: 0 align: 4        alloc type: 0   alive: false    address: 0
Block 1 >    size: 4 align: 1        alloc type: 0   alive: true     address: 4

Target:
<4 x i16> %#0 = < poison, poison, poison, poison >
<4 x i16> %#1 = < poison, poison, poison, poison >
<4 x i16> %#2 = < poison, poison, poison, poison >
<4 x i16> %#3 = < #x0001 (1), #x0000 (0), #x0000 (0), #x0000 (0) >
<4 x i16> %#4 = < poison, poison, poison, poison >
<4 x i16> %#5 = < poison, poison, poison, poison >
<4 x i16> %#6 = < poison, poison, poison, poison >
<2 x i16> %#7 = < #x0001 (1), poison >
<2 x i16> %#8 = < #x0001 (1), poison >
<4 x i16> %#9 = < #x0001 (1), #x0001 (1), #x0001 (1), poison >
<4 x i16> %#10 = < #x0001 (1), #x0001 (1), #x0001 (1), poison >
<4 x i16> %#17 = < poison, poison, poison, poison >
<4 x i16> %#18 = < poison, poison, poison, poison >
<4 x i1> %#19 = < poison, poison, poison, poison >
<4 x i1> %#20 = < poison, poison, poison, poison >
<4 x i16> %#21 = < #x0001 (1), #x0001 (1), #x0001 (1), poison >
<4 x i16> %#22 = < #x0001 (1), #x0001 (1), #x0001 (1), poison >
<4 x i16> %#23 = < #x0001 (1), #x0001 (1), #x0001 (1), poison >
<4 x i1> %#24 = < #x1 (1), #x1 (1), #x1 (1), poison >
<4 x i1> %#25 = < #x1 (1), #x1 (1), #x1 (1), poison >
<4 x i1> %#26 = < poison, poison, poison, poison >
<4 x i1> %#32 = < #x1 (1), #x1 (1), #x1 (1), #x1 (1) >
i1 %#33 = #x1 (1)
i32 %spec.select31 = #x00000000 (0)
i16 %#36 = #x0001 (1)
Source value: #x0000 (0)
Target value: #x0001 (1)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```

llvm version: 76fac9c01736b1254e42427f8e0910c0f1d01fba

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUW0tv4zgS_jXMhbBBFvU8-KC8Lts9WSS9A-ypIct0oh1ZMiQ5k-TXL0g9LIqkLCfuBmbQ8Mhm1UdW1afiJzqOqyp9zjlfIfcaubdX8aF-KcrVpk7ePt7_vloXm_fVI9-XxeaQ8BKxCL_U9b5CLEJwj-A-ztJXDssse90ti_IZwX3CEdx_ILi_Lva3P3JEIuSR9h-JELvG6zRHcF_sa7zYx1XFK8Ruq2y_eOVJXZTpBy9xzat6mWV48YRIVMflM6_xJq7jLH4vDjVG7BYjAL7YIRbxxR58gljEQL6It1R9K648R74s0v6CQoBYRCFYbAPSXuXyI69z95zFkzADOK6jLtN9xrs1vAXeT89ZHPK_8uLvfJGl-eFt8ZwfGhdEog3fpjnHKfUwcogIDEGwr0uMwN1TBDfNELhpniypw5ap71HmLbOkqmLqBkDIMl2mY8MlXaYBUBa2hh6hYWgydJgwDQPqQGcKNAwa0xAj_xqRiOd1-S6KSiIsPIkML8438-c8HUGLTcfYRLiTbhjGw1QZZnI4TXZ73GUVXFBMlnlRyxdpWpQ4pdJTGG3jrOKd4SAoscCj-cyQiQLUJdoGNVmIAZhjX4dm645sHWXUG426yqhvyqSnZdIfZbLJYFNwvzMM1FT3FWjtepzOPpzglxYkVdlIRmzrk97bawyjKsUomEKnR6INQ1hSNTYKZh41vBfrGHrMvLPtTLKCzeISZUPvceb69bYx0zH1KFPRxnSjKt-oZ8yrO86rr-V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