This is an archive of the discontinued LLVM Phabricator instance.

[x86] fix usage of stale operands in LowerSELECT
ClosedPublic

Authored by spatel on Jan 5 2017, 12:53 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 83288.Jan 5 2017, 12:53 PM
spatel retitled this revision from to [x86] fix usage of stale operands in LowerSELECT.
spatel updated this object.
spatel added reviewers: zvi, andreadb, craig.topper.
spatel added a subscriber: llvm-commits.
craig.topper accepted this revision.Jan 7 2017, 10:38 AM
craig.topper edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 7 2017, 10:38 AM
This revision was automatically updated to reflect the committed changes.