[PATCH] D63032: [X86] When promoting i16 compare with immediate to i32, try to use sign_extend for eq/ne if the input is truncated from a type with enough sign its.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 15:50:25 PDT 2019


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, xbolva00.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Our default behavior is to use sign_extend for signed comparisons and zero_extend for everything. But for equality we have the freedom to use either extension. If we can prove the input has been truncated from something with enough sign bits, we can use sign_extend instead and let DAG combine optimize it out. A similar rule is used by type legalization in LegalizeIntegerTypes.

This gets rid of the movzx in PR42189. The immediate will still take 4 bytes instead of the 2 bytes plus 0x66 prefix a cmp di, 32767 would get, but it avoids a length changing prefix.

I refactored this code to handle floating point first to remove one level indentation in the integer path. I can pre-commit some of the refactoring if reviewers want.


https://reviews.llvm.org/D63032

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/cmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63032.203637.patch
Type: text/x-patch
Size: 5141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190607/a2bc738c/attachment.bin>


More information about the llvm-commits mailing list