[llvm-bugs] [Bug 45955] New: Incorrect instcombine fold of vector bitwise of ((x ^ y) & const) ^ y

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 17 05:07:51 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45955

            Bug ID: 45955
           Summary: Incorrect instcombine fold of vector bitwise of ((x ^
                    y) & const) ^ y
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
                    regehr at cs.utah.edu, spatel+llvm at rotateright.com

Test: Transforms/InstCombine/unfold-masked-merge-with-const-mask-vector.ll
TL;DR: the transformation below needs to fix the newly introduced undef
constants

define <3 x i4> @splat_undef(<3 x i4> %x, <3 x i4> %y) {
  %n0 = xor <3 x i4> %x, %y
  %n1 = and <3 x i4> %n0, { 14, undef, 14 }
  %r = xor <3 x i4> %n1, %y
  ret <3 x i4> %r
}
=>
define <3 x i4> @splat_undef(<3 x i4> %x, <3 x i4> %y) {
  %1 = and <3 x i4> %x, { 14, undef, 14 }
  %2 = and <3 x i4> %y, { 1, undef, 1 }
  %r = or <3 x i4> %1, %2
  ret <3 x i4> %r
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
<3 x i4> %x = < #x0 (0), #xd (13, -3), #x0 (0) >
<3 x i4> %y = < undef, #x8 (8, -8), #x0 (0) >

Source:
<3 x i4> %n0 = < #x0 (0), #x5 (5), #x0 (0) >
<3 x i4> %n1 = < #x0 (0), #x0 (0)       [based on undef value], #x0 (0) >
<3 x i4> %r = < #x0 (0), #x8 (8, -8), #x0 (0) >

Target:
<3 x i4> %1 = < #x0 (0), #x1 (1), #x0 (0) >
<3 x i4> %2 = < #x0 (0), #x0 (0), #x0 (0) >
<3 x i4> %r = < #x0 (0), #x1 (1), #x0 (0) >
Source value: < #x0 (0), #x8 (8, -8), #x0 (0) >
Target value: < #x0 (0), #x1 (1), #x0 (0) >


https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=72296a443c683892&test=Transforms%2FInstCombine%2Funfold-masked-merge-with-const-mask-vector.ll

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200517/a8967c1b/attachment-0001.html>


More information about the llvm-bugs mailing list