[PATCH] When canonicalizing gep indices, prefer zext when possible

Philip Reames listmail at philipreames.com
Thu Jan 29 08:21:12 PST 2015


Hi baldrick, craig.topper, sunfish, echristo, tstellarAMD,

We eagerly canonicalize gep indices to the width of a machine register (i64 on x86_64).  To do so, we insert sign extensions (sext) to promote smaller types.  This change substitutes zero extensions where we know the value being extended is positive.  This is motivated by the fact that zero extensions are generally cheaper on x86.

Q for reviewer: Should this be behind a target hook?  If so, which and how?

On a broader topic, I don't really get why we're canonicalizing this way at all.  Does anyone have a strong reason why this is right approach?

http://reviews.llvm.org/D7255

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/Transforms/InstCombine/InstCombineCasts.cpp
  lib/Transforms/InstCombine/InstructionCombining.cpp
  test/CodeGen/X86/gep-sext.ll
  test/Transforms/InstCombine/gep-sext.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7255.18929.patch
Type: text/x-patch
Size: 6376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150129/403ead17/attachment.bin>


More information about the llvm-commits mailing list