[all-commits] [llvm/llvm-project] ed3f06: [IR] Add zext nneg flag (#67982)

Nikita Popov via All-commits all-commits at lists.llvm.org
Mon Oct 30 01:04:18 PDT 2023


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

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/AsmParser/LLToken.h
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/include/llvm/IR/Instruction.h
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/IR/Operator.cpp
    M llvm/test/Assembler/flags.ll
    M llvm/test/Bitcode/flags.ll
    M llvm/test/Transforms/InstCombine/freeze.ll
    M llvm/test/Transforms/SimplifyCFG/HoistCode.ll

  Log Message:
  -----------
  [IR] Add zext nneg flag (#67982)

Add an nneg flag to the zext instruction, which specifies that the
argument is non-negative. Otherwise, the result is a poison value.

The primary use-case for the flag is to preserve information when sext
gets replaced with zext due to range-based canonicalization. The nneg
flag allows us to convert the zext back into an sext later. This is
useful for some optimizations (e.g. a signed icmp can fold with sext but
not zext), as well as some targets (e.g. RISCV prefers sext over zext).

Discourse thread: https://discourse.llvm.org/t/rfc-add-zext-nneg-flag/73914

This patch is based on https://reviews.llvm.org/D156444 by
@Panagiotis156, with some implementation simplifications and additional
tests.

---------

Co-authored-by: Panagiotis K <karouzakispan at gmail.com>




More information about the All-commits mailing list