Skip to content
Unverified Commit 20ae2d20 authored by Dhruv Chawla's avatar Dhruv Chawla
Browse files

[InstCombine] Generalize foldAndOrOfICmpEqZeroAndICmp

This patch generalizes the fold implemented by foldAndOrOfICmpEqZeroAndICmp,
which are:

(icmp eq X, 0) | (icmp ult Other, X) -> (icmp ule Other, X-1)
(icmp ne X, 0) & (icmp uge Other, X) -> (icmp ugt Other, X-1)

to the following:

(icmp eq X, C) | (icmp ult Other, (X - C)) -> (icmp ule Other, (X - (C + 1)))
(icmp ne X, C) & (icmp uge Other, (X - C)) -> (icmp ugt Other, (X - (C + 1)))

The function foldAndOrOfICmpEqZeroAndICmp is also renamed to
foldAndOrOfICmpEqConstantAndICmp to reflect the changes.

Proofs: https://alive2.llvm.org/ce/z/yXGv6q

Fixes #63749.

Differential Revision: https://reviews.llvm.org/D154937
parent b336f9de
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment