This is an archive of the discontinued LLVM Phabricator instance.

[X86] Don't allow optimizeCompareInstr to replace a CMP with BEXTR if the sign flag is used.
ClosedPublic

Authored by craig.topper on Dec 17 2018, 9:14 PM.

Details

Summary

The BEXTR instruction documents the SF bit as undefined.

The TBM BEXTR instruction has the same issue, but I'm not sure how to test it. With the control being an immediate we can determine the sign bit is 0 or the BEXTR would have been removed.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 17 2018, 9:14 PM

At some point we're probably going to have to properly tag what state each flag bit is in after an instruction - I think @andreadb is keen on this for llvm-mca as well to account for different cpus splitting the eflags into different partial registers.

lib/Target/X86/X86InstrInfo.cpp
3457

Update comment.

3562

Align the indentation.

RKSimon accepted this revision.Dec 21 2018, 10:56 AM

Oops, forgot the LGTM

This revision is now accepted and ready to land.Dec 21 2018, 10:56 AM
This revision was automatically updated to reflect the committed changes.