[InstCombine] Fix infinite loop in min/max load/store bitcast combine (PR44835)
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 8 Feb 2020 11:04:58 +0000 (12:04 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 8 Feb 2020 15:55:22 +0000 (16:55 +0100)
commit23db9724d0e5490fa5a2a726acf015f84e2c87cf
treed9083122c1c516d0ea3d8e81e718abf39ff8ca53
parentc8bc89a933fc5e6fe160cffbd6e6a0aca0277cd9
[InstCombine] Fix infinite loop in min/max load/store bitcast combine (PR44835)

Fixes https://bugs.llvm.org/show_bug.cgi?id=44835. Skip the transform
if it wouldn't actually do anything (apart from removing and reinserting
the same instructions).

Note that the test case doesn't loop on current master anymore, only
on the LLVM 10 release branch. The issue is already mitigated on master
due to worklist order fixes, but we should fix the root cause there as well.

As a side note, we should probably assert in combineLoadToNewType()
that it does not combine to the same type. Not doing this here, because
this assertion would also be triggered in another place right now.

Differential Revision: https://reviews.llvm.org/D74278
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/pr44835.ll [new file with mode: 0644]