[PATCH] D124894: Prefer 32bit and 64bit switch conditions for x86

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 18:16:59 PDT 2022


MatzeB created this revision.
MatzeB added reviewers: spatel, craig.topper.
Herald added subscribers: StephenFan, modimo, wenlei, pengfei, hiraditya, mcrosier.
Herald added a project: All.
MatzeB requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds a `TargetLoweringBase::shouldExtendSwitch` callback to give targets a chance to control the preferred types in `CodeGenPrepare::optimizeSwitchInst`.

Implement it for X86 and choose i32 and i64 types where possible as they can be used immediately in address calculations. Previously we would use types like i8 or i16, while they are legal types on X86 they require additional zero extension operations before we can use them in address calculations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124894

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/X86/2008-12-01-loop-iv-used-outside-loop.ll
  llvm/test/CodeGen/X86/SwitchLowering.ll
  llvm/test/CodeGen/X86/conditional-tailcall.ll
  llvm/test/CodeGen/X86/switch-phi-const.ll
  llvm/test/CodeGen/X86/switch.ll
  llvm/test/CodeGen/X86/tail-dup-multiple-latch-loop.ll
  llvm/test/CodeGen/X86/tail-opts.ll
  llvm/test/Transforms/CodeGenPrepare/X86/widen_switch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124894.426885.patch
Type: text/x-patch
Size: 27259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/69346432/attachment.bin>


More information about the llvm-commits mailing list