[all-commits] [llvm/llvm-project] 3b2540: [IR] Mark zext/sext constant expressions as undesi...

Nikita Popov via All-commits all-commits at lists.llvm.org
Mon Oct 2 03:40:39 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b25407d977d9ed3dbcaccd4f8850b65e95d70fd
      https://github.com/llvm/llvm-project/commit/3b25407d977d9ed3dbcaccd4f8850b65e95d70fd
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-10-02 (Mon, 02 Oct 2023)

  Changed paths:
    M clang/test/CodeGen/constantexpr-fneg.c
    M clang/test/CodeGenCXX/weak-external.cpp
    M clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
    M llvm/include/llvm/Analysis/TargetFolder.h
    M llvm/include/llvm/IR/ConstantFolder.h
    M llvm/include/llvm/IR/Constants.h
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/lib/IR/Constants.cpp
    M llvm/lib/Transforms/Utils/SCCPSolver.cpp
    M llvm/test/Transforms/InstCombine/constant-fold-shifts.ll
    M llvm/test/Transforms/InstCombine/gep-custom-dl.ll
    M llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
    M llvm/test/Transforms/LowerTypeTests/import.ll
    M llvm/test/Transforms/LowerTypeTests/simplify.ll

  Log Message:
  -----------
  [IR] Mark zext/sext constant expressions as undesirable

Introduce isDesirableCastOp() which determines whether IR builder
and constant folding should produce constant expressions for a
given cast type. This mirrors what we do for binary operators.

Mark zext/sext as undesirable, which prevents most creations of such
constant expressions. This is still somewhat incomplete and there
are a few more places that can create zext/sext expressions.

This is part of the work for
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.

The reason for the odd result in the constantexpr-fneg.c test is
that initially the "a[]" global is created with an [0 x i32] type,
at which point the icmp expression cannot be folded. Later it is
replaced with an [1 x i32] global and the icmp gets folded away.
But at that point we no longer fold the zext.




More information about the All-commits mailing list