[llvm-bugs] [Bug 40325] New: [Mips] FastISel fails to mask branch conditions

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 15 13:41:54 PST 2019


            Bug ID: 40325
           Summary: [Mips] FastISel fails to mask branch conditions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: MIPS
          Assignee: unassignedbugs at nondot.org
          Reporter: nikita.ppv at gmail.com
                CC: llvm-bugs at lists.llvm.org

Originally reported at: https://github.com/rust-lang/rust/issues/57631

Test case:

define void @test(i32 %x, i1* %p) {
  %y = and i32 %x, 1
  %c = icmp eq i32 %y, 1
  store i1 %c, i1* %p
  br i1 %c, label %foo, label %foo

  ret void

Running this through llc -march=mipsel -mcpu=mips32 -relocation-model=pic -O0

# %bb.0:
        move    $1, $4
        andi    $4, $4, 1
        sb      $4, 0($5)
        bgtz    $1, $BB0_1
# %bb.1:                                # %foo
        jr      $ra

While the sb is correct, the bgtz argument is the unmasked function argument.

The cause is very similar to https://bugs.llvm.org/show_bug.cgi?id=40172. In
an icmp result stored in an i32 virtual register is assumed to have only value
0 or 1, while in reality only the low-bit of the register has a well-defined

a variant of this issue affecting i1 icmps was fixed. However, the issue is
more general than that and can occur with arbitrary icmps if they come from a
SelectionDAG fallback and happen to be combined in just the right way.

I believe the correct way to handle this is to fastEmitZExtFromI1() the branch
condition (even though this will regress FastISel code quality).

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/20190115/d57ed17b/attachment.html>

More information about the llvm-bugs mailing list