[all-commits] [llvm/llvm-project] 866be0: [RISCV] Pre-commit test for PR56457. NFC

Craig Topper via All-commits all-commits at lists.llvm.org
Tue Jul 12 11:37:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 866be0aa8ae40913a9ad999d9b4c525d3f15a129
      https://github.com/llvm/llvm-project/commit/866be0aa8ae40913a9ad999d9b4c525d3f15a129
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2022-07-12 (Tue, 12 Jul 2022)

  Changed paths:
    A llvm/test/CodeGen/RISCV/pr56457.ll

  Log Message:
  -----------
  [RISCV] Pre-commit test for PR56457. NFC


  Commit: 8eaf00e04dba1b98acf8031b61d9488387a1066e
      https://github.com/llvm/llvm-project/commit/8eaf00e04dba1b98acf8031b61d9488387a1066e
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2022-07-12 (Tue, 12 Jul 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/test/CodeGen/RISCV/pr56457.ll

  Log Message:
  -----------
  [TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types.

To convert CTLZ to popcount we do

x = x | (x >> 1);
x = x | (x >> 2);
...
x = x | (x >>16);
x = x | (x >>32); // for 64-bit input
return popcount(~x);

This smears the most significant set bit across all of the bits
below it then inverts the remaining 0s and does a population count.

To support non-power of 2 types, the last shift amount must be
more than half of the size of the type. For i15, the last shift
was previously a shift by 4, with this patch we add another shift
of 8.

Fixes PR56457.

Differential Revision: https://reviews.llvm.org/D129431


Compare: https://github.com/llvm/llvm-project/compare/2324c2e3c311...8eaf00e04dba


More information about the All-commits mailing list