[PATCH] Optimize sext/zext insertion algorithm in back-end

Jiangning Liu liujiangning1 at gmail.com
Mon Sep 8 20:01:10 PDT 2014


Hi t.p.northover,

This is the updated patch for reverted patch "r216066 - Optimize ZERO_EXTEND and SIGN_EXTEND in both SelectionDAG Builder and type".

The solution of r216066 slowed down a huge case reported by Rafael, so it was reverted. The root cause is CopyValueToVirtualRegisters in SelectionDAGBuilder is called too many times in back-end, and my original algorithm was to check all users for a value, so the time complexity could increase from O(n) to O(n^2) specifically for this feature.

The new solution tries to do early decision making before real ISEL stage, and get the sext/zext preferences stored into FuncInfo. We can do this because deciding preferred sext/zext doesn't depend on SDNode but LLVM IR. This way, we will be able to calculate the info once and use it many times in real ISEL stage.

With this patch, we won't see any slowdown for the test case at https://drive.google.com/file/d/0B7iRtublysV6RVpFUGNxaUcwc1E/edit?usp=sharing, which is a huge one.

Thanks,
-Jiangning

http://reviews.llvm.org/D5257

Files:
  include/llvm/CodeGen/FunctionLoweringInfo.h
  lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/AArch64/atomic-ops.ll
  test/CodeGen/AArch64/rm_redundant_cmp.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5257.13438.patch
Type: text/x-patch
Size: 17536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140909/d1b86f80/attachment.bin>


More information about the llvm-commits mailing list