[PATCH] D39267: [GISel]: Change Legalization from top down to bottom up + DCE

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 17:20:09 PST 2017


aditya_nandakumar updated this revision to Diff 121819.
aditya_nandakumar added a comment.

Legalization Artifacts are all those insts that are there to make the type system happy. Currently, the target needs to say all combinations of extends and truncs are legal and there's no way of verifying that post legalization, we only have *truly* legal instructions. This patch changes roughly the legalization algorithm to process all illegal insts at one go, and then process all truncs/extends that were added to satisfy the type constraints separately trying to combine trivial cases until they converge. This has the added benefit that, the target legalizerinfo can only say which truncs and extends are okay and the artifact combiner would combine away other exts and truncs.

Updated legalization algorithm to roughly the following pseudo code.

WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);

do {

  for (Inst in Insts)
       legalizeInstrStep(Inst, Insts, Artifacts);
  for (Artifact in Artifacts)
       tryCombineArtifact(Artifact, Insts, Artifacts);

} while(!Insts.empty());

Also, wrote a simple wrapper equivalent to SetVector, except for erasing, it avoids moving all elements over by one and instead just nulls them out.


https://reviews.llvm.org/D39267

Files:
  include/llvm/CodeGen/GlobalISel/GISelWorkList.h
  include/llvm/CodeGen/GlobalISel/LegalizerCombiner.h
  lib/CodeGen/GlobalISel/Legalizer.cpp
  test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
  test/CodeGen/AArch64/GlobalISel/legalize-add.mir
  test/CodeGen/AArch64/GlobalISel/legalize-and.mir
  test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
  test/CodeGen/AArch64/GlobalISel/legalize-combines.mir
  test/CodeGen/AArch64/GlobalISel/legalize-constant.mir
  test/CodeGen/AArch64/GlobalISel/legalize-div.mir
  test/CodeGen/AArch64/GlobalISel/legalize-ext.mir
  test/CodeGen/AArch64/GlobalISel/legalize-extracts.mir
  test/CodeGen/AArch64/GlobalISel/legalize-fcmp.mir
  test/CodeGen/AArch64/GlobalISel/legalize-fptoi.mir
  test/CodeGen/AArch64/GlobalISel/legalize-inserts.mir
  test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir
  test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir
  test/CodeGen/AArch64/GlobalISel/legalize-mul.mir
  test/CodeGen/AArch64/GlobalISel/legalize-nonpowerof2eltsvec.mir
  test/CodeGen/AArch64/GlobalISel/legalize-or.mir
  test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
  test/CodeGen/AArch64/GlobalISel/legalize-pow.mir
  test/CodeGen/AArch64/GlobalISel/legalize-rem.mir
  test/CodeGen/AArch64/GlobalISel/legalize-shift.mir
  test/CodeGen/AArch64/GlobalISel/legalize-simple.mir
  test/CodeGen/AArch64/GlobalISel/legalize-sub.mir
  test/CodeGen/AArch64/GlobalISel/legalize-undef.mir
  test/CodeGen/AArch64/GlobalISel/legalize-vaarg.mir
  test/CodeGen/AArch64/GlobalISel/legalize-xor.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-add.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-and.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-bitcast.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-fmul.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-icmp.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-or.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-select.mir
  test/CodeGen/AMDGPU/GlobalISel/legalize-shl.mir
  test/CodeGen/ARM/GlobalISel/arm-isel.ll
  test/CodeGen/ARM/GlobalISel/arm-legalize-divmod.mir
  test/CodeGen/X86/GlobalISel/add-scalar.ll
  test/CodeGen/X86/GlobalISel/and-scalar.ll
  test/CodeGen/X86/GlobalISel/ext.ll
  test/CodeGen/X86/GlobalISel/legalize-add-v128.mir
  test/CodeGen/X86/GlobalISel/legalize-add-v256.mir
  test/CodeGen/X86/GlobalISel/legalize-add-v512.mir
  test/CodeGen/X86/GlobalISel/legalize-add.mir
  test/CodeGen/X86/GlobalISel/legalize-and-scalar.mir
  test/CodeGen/X86/GlobalISel/legalize-constant.mir
  test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir
  test/CodeGen/X86/GlobalISel/legalize-ext.mir
  test/CodeGen/X86/GlobalISel/legalize-gep.mir
  test/CodeGen/X86/GlobalISel/legalize-memop-scalar.mir
  test/CodeGen/X86/GlobalISel/legalize-mul-scalar.mir
  test/CodeGen/X86/GlobalISel/legalize-or-scalar.mir
  test/CodeGen/X86/GlobalISel/legalize-phi.mir
  test/CodeGen/X86/GlobalISel/legalize-sub-v128.mir
  test/CodeGen/X86/GlobalISel/legalize-sub-v256.mir
  test/CodeGen/X86/GlobalISel/legalize-sub-v512.mir
  test/CodeGen/X86/GlobalISel/legalize-sub.mir
  test/CodeGen/X86/GlobalISel/legalize-trunc.mir
  test/CodeGen/X86/GlobalISel/legalize-undef.mir
  test/CodeGen/X86/GlobalISel/legalize-xor-scalar.mir
  test/CodeGen/X86/GlobalISel/or-scalar.ll
  test/CodeGen/X86/GlobalISel/sub-scalar.ll
  test/CodeGen/X86/GlobalISel/x86_64-fallback.ll
  test/CodeGen/X86/GlobalISel/xor-scalar.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39267.121819.patch
Type: text/x-patch
Size: 198670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171107/6fe136a5/attachment-0001.bin>


More information about the llvm-commits mailing list