[all-commits] [llvm/llvm-project] 84b026: DAG: Pass flags to FoldConstantArithmetic (#93663)

Matt Arsenault via All-commits all-commits at lists.llvm.org
Thu Jun 6 07:44:29 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84b026690ded7f7728b6d1ba48b233b6ca8317eb
      https://github.com/llvm/llvm-project/commit/84b026690ded7f7728b6d1ba48b233b6ca8317eb
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2024-06-06 (Thu, 06 Jun 2024)

  Changed paths:
    M llvm/include/llvm/CodeGen/SelectionDAG.h
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll
    M llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll
    M llvm/test/CodeGen/AMDGPU/llvm.maximum.f16.ll
    M llvm/test/CodeGen/WebAssembly/simd-arith.ll

  Log Message:
  -----------
  DAG: Pass flags to FoldConstantArithmetic (#93663)

There is simply way too much going on inside getNode. The complicated
constant folding of vector handling works by looking for build_vector
operands, and then tries to getNode the scalar element and then checks
if
constants were the result. As a side effect, this produces unused scalar
operation nodes (previously, without flags). If the vector operation
were later scalarized, it would find the flagless constant folding
temporary and lose the flag. I don't think this is a reasonable way for
constant folding to operate, but for now fix this by ensuring flags
on the original operation are preserved in the temporary.
    
This yields a clear code improvement for AMDGPU when f16 isn't legal.
The Wasm cases switch from using a libcall to compare and select. We are
evidently
missing the fcmp+select to fminimum/fmaximum handling, but this would be
further
improved when that's handled. AArch64 also avoids the libcall, but looks
worse and
has a different call for some reason.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list