[PATCH] D40055: [SelectionDAG][X86] Explicitly store the scale in the gather/scatter ISD nodes

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 15:43:01 PST 2017


craig.topper created this revision.

Currently we infer the scale at isel time by analyzing whether the base is a constant 0 or not. If it is we assume scale is 1, else we take it from the element size of the pass thru or stored value. This seems a little weird and I think it makes more sense to make it explicit in the DAG rather than doing tricky things in the backend.

Most of this patch is just making sure we copy the scale around everywhere.

The test changes are interesting because I believe the current codegen is actually a bug. We seem to be promote v2i32 gathers to v2i64 and double the scale. But really the address calculation shouldn't have been affected. This is a consquence of getting the scale from the data size. With it stored explicitly it comes from the original GEP. I don't think we should be promoting v2i32 gathers to v2i64, the IR we started with only  said it was legal to read 32 bits at each index. If one of the elements is at the end of an array near a page boundary the extra data read might cause a fault. I'll look into a fixing this as a separate patch.


https://reviews.llvm.org/D40055

Files:
  include/llvm/CodeGen/SelectionDAGNodes.h
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/Target/X86/X86ISelDAGToDAG.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  test/CodeGen/X86/masked_gather_scatter.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40055.122931.patch
Type: text/x-patch
Size: 17901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171114/92a39218/attachment.bin>


More information about the llvm-commits mailing list