[InstCombine] Fix infinite min/max canonicalization loop (PR44541)
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 2 Feb 2020 16:40:15 +0000 (17:40 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 8 Feb 2020 19:42:17 +0000 (20:42 +0100)
commita148b9e9909db6a592609eb35b4de38c9e67cb8b
tree768df60dd754ce9a5ca3c00f9507b6b46b04cf4a
parent5c159b91a24b07974328ab17fd56a244995f2944
[InstCombine] Fix infinite min/max canonicalization loop (PR44541)

While D72944 also fixes https://bugs.llvm.org/show_bug.cgi?id=44541,
it does so in a more roundabout manner and there might be other
loopholes to trigger the same issue. This is a more direct fix,
that prevents the transform if the min/max is based on a
non-canonical sub X, 0 instruction.

Differential Revision: https://reviews.llvm.org/D73849
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/pr44541.ll [new file with mode: 0644]