HomePhabricator

Improve codegen for deque.

Authored by EricWF on Aug 12 2019, 12:51 AM.

Description

Improve codegen for deque.

This patch rewrites a few loops in deque and split_buffer to better
optimize the codegen. For constructors like
deque<unsigned char> d(500000, 0); this patch results in a 2x speedup.

The patch improves the codegen in roughly three ways:

  1. Changes do { ... } while (...) loops into more typical for loops. The optimizer can reason about normal looking loops better.
  1. Split the iteration over a range into (A) iteration over the blocks,

then (B) iteration within the block. This nested structure helps LLVM
lower the inner loop to memset.

  1. Do fewer things each iteration. Some of these loops were incrementing or changing 4-5 variables every loop (in addition to the construction). Previously most loops would increment the end pointer, the size, and decrement the count of remaining items to construct. Now we only increment a single pointer for most iterations.

llvm-svn: 368547

Details

Committed
EricWFAug 12 2019, 12:51 AM
Parents
rGfd5ea1b0d904: [clangd] Highlighting auto variables as the deduced type.
Branches
Unknown
Tags
Unknown