OSDN Git Service

[X86][FastISel] Fix with.overflow eflags clobber (PR49587)
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 14 Mar 2021 15:47:41 +0000 (16:47 +0100)
committerTom Stellard <tstellar@redhat.com>
Tue, 30 Mar 2021 21:27:00 +0000 (14:27 -0700)
commit38dd45b00431e2c065e172751492e0ded59e49e6
treed9133200d9ce3983911a3b0359d9a58e97b95257
parent79a79d1d01c4c206d8de3569c72747587d929770
[X86][FastISel] Fix with.overflow eflags clobber (PR49587)

If the successor block has a phi node, then additional moves may
be inserted into predecessors, which may clobber eflags. Don't try
to fold the with.overflow result into the branch in that case.

This is done by explicitly checking for any phis in successor
blocks, not sure if there's some more principled way to address
this. Other fused compare and branch patterns avoid the issue by
emitting the comparison when handling the branch, so that no
instructions may be inserted in between. In this case, the
with.overflow call is emitted separately (and I don't think this
is avoidable, as it will generally have at least two users).

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

Differential Revision: https://reviews.llvm.org/D98600

(cherry picked from commit 7669455df49e6fc8ae7d9f4bd4ee95bb20e7eb6e)
llvm/lib/Target/X86/X86FastISel.cpp
llvm/test/CodeGen/X86/pr49587.ll