[PATCH] D101074: [X86] Canonicalize SGT/UGT compares with constants to use SGE/UGE to reduce the number of EFLAGs reads. (PR48760)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 08:21:10 PDT 2021


RKSimon created this revision.
RKSimon added reviewers: craig.topper, spatel, lebedev.ri, dblaikie, pengfei.
Herald added subscribers: jfb, hiraditya.
RKSimon requested review of this revision.
Herald added a project: LLVM.

This demonstrates a possible fix for PR48760 - for compares with constants, canonicalize the SGT/UGT condition code to use SGE/UGE which should reduce the number of EFLAGs bits we need to read.

As discussed on PR48760, some EFLAG bits are treated independently which can require additional uops to merge together for certain CMOVcc/SETcc/etc. modes.

I've limited this to cases where the constant increment doesn't result in an larger encoding - but there are still a few codegen changes I'm not sure about - it looks like there's other problems with flags reuse with atomic ops, and some min/max-like patterns lose out because the comparison constant is now different from the select value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101074

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/2008-09-11-CoalescerBug2.ll
  llvm/test/CodeGen/X86/atomic-eflags-reuse.ll
  llvm/test/CodeGen/X86/cmov.ll
  llvm/test/CodeGen/X86/lack-of-signed-truncation-check.ll
  llvm/test/CodeGen/X86/mul-constant-result.ll
  llvm/test/CodeGen/X86/or-branch.ll
  llvm/test/CodeGen/X86/pr45995-2.ll
  llvm/test/CodeGen/X86/pr5145.ll
  llvm/test/CodeGen/X86/sadd_sat.ll
  llvm/test/CodeGen/X86/sadd_sat_plus.ll
  llvm/test/CodeGen/X86/sdiv_fix_sat.ll
  llvm/test/CodeGen/X86/select.ll
  llvm/test/CodeGen/X86/select_const.ll
  llvm/test/CodeGen/X86/setcc-logic.ll
  llvm/test/CodeGen/X86/setcc.ll
  llvm/test/CodeGen/X86/smul_fix_sat.ll
  llvm/test/CodeGen/X86/smul_fix_sat_constants.ll
  llvm/test/CodeGen/X86/srem-seteq.ll
  llvm/test/CodeGen/X86/ssub_sat.ll
  llvm/test/CodeGen/X86/ssub_sat_plus.ll
  llvm/test/CodeGen/X86/umul_fix_sat.ll
  llvm/test/CodeGen/X86/urem-seteq-illegal-types.ll
  llvm/test/CodeGen/X86/urem-seteq.ll
  llvm/test/CodeGen/X86/vector-mulfix-legalize.ll
  llvm/test/CodeGen/X86/zext-sext.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101074.339650.patch
Type: text/x-patch
Size: 56928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210422/8b70445e/attachment.bin>


More information about the llvm-commits mailing list