Revert "[ValueTracking][InstCombine] Add a new API to allow to ignore poison generati...
authorFlorian Hahn <flo@fhahn.com>
Mon, 29 May 2023 14:44:35 +0000 (15:44 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 29 May 2023 14:44:37 +0000 (15:44 +0100)
commitcd2fc73b49851540b06f91e89a42bdc5affa7e49
treee0be6d048d1c106ddc4e0365563e986f13997219
parentab05d9134d18db34501985a01fbfc02609767587
Revert "[ValueTracking][InstCombine] Add a new API to allow to ignore poison generating flags or metadatas when implying poison"

This reverts commit 754f3ae65518331b7175d7a9b4a124523ebe6eac.

Unfortunately the change can cause regressions due to dropping flags
from instructions (like nuw,nsw,inbounds), prevent further optimizations
depending on those flags.

A simple example is the IR below, where `inbounds` is dropped with the
patch and the phase-ordering test added in 7c91d82ab912fae8b.

    define i1 @test(ptr %base, i64 noundef %len, ptr %p2) {
    bb:
      %gep = getelementptr inbounds i32, ptr %base, i64 %len
      %c.1 = icmp uge ptr %p2, %base
      %c.2 = icmp ult ptr %p2, %gep
      %select = select i1 %c.1, i1 %c.2, i1 false
      ret i1 %select
    }

For more discussion, see D149404.
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/ispow2.ll
llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll
llvm/test/Transforms/PhaseOrdering/iterator-with-runtime-check.ll