Skip to content
Unverified Commit ed3f06b9 authored by Nikita Popov's avatar Nikita Popov Committed by GitHub
Browse files

[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: default avatarPanagiotis K <karouzakispan@gmail.com>
parent 41f3b83f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment