[all-commits] [llvm/llvm-project] e5e93b: [DAG] FoldConstantArithmetic - add initial support...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Mon Aug 8 03:54:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e5e93b6130bde96d7e14851e218c5bf055f8a834
      https://github.com/llvm/llvm-project/commit/e5e93b6130bde96d7e14851e218c5bf055f8a834
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2022-08-08 (Mon, 08 Aug 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/ARM/srem-seteq-illegal-types.ll
    M llvm/test/CodeGen/RISCV/srem-seteq-illegal-types.ll
    M llvm/test/CodeGen/Thumb2/srem-seteq-illegal-types.ll
    M llvm/test/CodeGen/X86/fshl-splat-undef.ll

  Log Message:
  -----------
  [DAG] FoldConstantArithmetic - add initial support for undef elements in bitcasted binop constant folding

FoldConstantArithmetic can fold constant vectors hidden behind bitcasts (e.g. vXi64 -> v2Xi32 on 32-bit platforms), but currently bails if either vector contains undef elements. These undefs can often occur due to SimplifyDemandedBits/VectorElts calls recognising that the upper bits are often unnecessary (e.g. funnel-shift/rotate implicit-modulo and AND masks).

This patch adds a basic 'FoldValueWithUndef' handler that will attempt to constant fold if one or both of the ops are undef - so far this just handles the AND and MUL cases where we always fold to zero.

The RISCV codegen increase is interesting - it looks like the BUILD_VECTOR lowering was loading a constant pool entry but now (with all elements defined constant) it can materialize the constant instead?

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




More information about the All-commits mailing list