<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X86] Bad codegen for i128 equality comparison"
   href="https://bugs.llvm.org/show_bug.cgi?id=41971">41971</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] Bad codegen for i128 equality comparison
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Originally reported at <a href="https://github.com/rust-lang/rust/issues/60994">https://github.com/rust-lang/rust/issues/60994</a>.

define i1 @foo(i128 %a, i128 %b) {
  %r = icmp eq i128 %a, %b
  ret i1 %r
}

generates:

        movq    xmm0, rcx
        movq    xmm1, rdx
        punpcklqdq      xmm1, xmm0      # xmm1 = xmm1[0],xmm0[0]
        movq    xmm0, rsi
        movq    xmm2, rdi
        punpcklqdq      xmm2, xmm0      # xmm2 = xmm2[0],xmm0[0]
        pcmpeqb xmm2, xmm1
        pmovmskb        eax, xmm2
        cmp     eax, 65535
        sete    al
        ret

The first DAG combine run goes from

          t2: i64,ch = CopyFromReg t0, Register:i64 %0
          t4: i64,ch = CopyFromReg t0, Register:i64 %1
        t9: i128 = build_pair t2, t4
          t6: i64,ch = CopyFromReg t0, Register:i64 %2
          t8: i64,ch = CopyFromReg t0, Register:i64 %3
        t10: i128 = build_pair t6, t8
      t12: i1 = setcc t9, t10, seteq:ch

to

                t2: i64,ch = CopyFromReg t0, Register:i64 %0
                t4: i64,ch = CopyFromReg t0, Register:i64 %1
              t9: i128 = build_pair t2, t4
            t20: v16i8 = bitcast t9
                t6: i64,ch = CopyFromReg t0, Register:i64 %2
                t8: i64,ch = CopyFromReg t0, Register:i64 %3
              t10: i128 = build_pair t6, t8
            t21: v16i8 = bitcast t10
          t22: v16i8 = setcc t20, t21, seteq:ch
        t23: i32 = X86ISD::MOVMSK t22
      t25: i1 = setcc t23, Constant:i32<65535>, seteq:ch

The offending transform is combineVectorSizedSetCCEquality().

Adding an early bailout if the operands are BUILD_PAIR fixes this specific
issue, but I don't think it really addresses the underlying problem. The
transform as a whole seems rather questionable outside of specific cases such
as the i128s coming from loads.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>