[llvm-bugs] [Bug 44383] New: Instcombine: incorrect transformation 'x > (x & undef)' -> 'x > undef'

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 26 11:39:34 PST 2019


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

            Bug ID: 44383
           Summary: Instcombine: incorrect transformation 'x > (x &
                    undef)' -> 'x > undef'
           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

The following transformation in
Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll
is incorrect:

define <3 x i1> @p3_vec_splat_undef() {
  %x = call <3 x i8> @gen3x8()
  %tmp0 = and <3 x i8> %x, { 3, undef, 3 }
  %ret = icmp sgt <3 x i8> %x, %tmp0
  ret <3 x i1> %ret
}
=>
define <3 x i1> @p3_vec_splat_undef() {

  %x = call <3 x i8> @gen3x8()
  %1 = icmp sgt <3 x i8> %x, { 3, undef, 3 }
  ret <3 x i1> %1
}

Transformation doesn't verify!
ERROR: Value mismatch

Example:

Source:
<3 x i8> %x = < poison, #x00 (0), poison >
<3 x i8> %tmp0 = < poison, #x00 (0), poison >
<3 x i1> %ret = < poison, #x0 (0), poison >

Target:
<3 x i8> %x = < poison, #x00 (0), poison >
<3 x i1> %1 = < poison, #x1 (1), poison >
Source value: < poison, #x0 (0), poison >
Target value: < poison, #x1 (1), poison >


The transformation does 'x > (x & undef)' -> 'x > undef'.
Take x=0, undef=-1, and we get '0 > 0' -> '0 > -1'.

-- 
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/20191226/06bb5068/attachment.html>


More information about the llvm-bugs mailing list