OSDN Git Service

[x86] fix usage of stale operands when lowering select
authorSanjay Patel <spatel@rotateright.com>
Sun, 8 Jan 2017 15:53:40 +0000 (15:53 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 8 Jan 2017 15:53:40 +0000 (15:53 +0000)
commitf204b67b4dc43f4aebcfa8ede3ad373edff3d369
tree332123bb7650590a82596b651bf15e866df2425c
parent35f85cb068a3918ceb18d5c386f5f602b88c7d92
[x86] fix usage of stale operands when lowering select

I noticed this problem as part of the ongoing attempt to canonicalize min/max ops in IR.

The debug output shows nodes like this:

t4: i32 = xor t2, Constant:i32<-1>
    t21: i8 = setcc t4, Constant:i32<0>, setlt:ch
  t14: i32 = select t21, t4, Constant:i32<-1>

And because the select is holding onto the t4 (xor) node while EmitTest creates a new
x86-specific xor node, the lowering results in:

  t4: i32 = xor t2, Constant:i32<-1>
  t25: i32,i32 = X86ISD::XOR t2, Constant:i32<-1>
t28: i32,glue = X86ISD::CMOV Constant:i32<-1>, t4, Constant:i8<15>, t25:1

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291392 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/cmov.ll