[InstCombine] isFreeToInvert(): constant expressions aren't free to invert (PR50370)
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 17 May 2021 11:53:53 +0000 (14:53 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 17 May 2021 11:58:05 +0000 (14:58 +0300)
commite35a9ecf3df8f26ce50f8429cbaaf5a0e0212e86
treedab9322ec2b861497f4d4c5d941fcbb053374903
parent0863d06050eb3bbf04a60aabed81e1712c7b7442
[InstCombine] isFreeToInvert(): constant expressions aren't free to invert (PR50370)

This fixes https://bugs.llvm.org/show_bug.cgi?id=50370,
which reports a yet another endless combine loop,
this one regressed from 554b1bced325a8d860ad00bd59020d66d01c95f8,
which fixed yet another endless combine loop (PR50308)

This code had fallen into the very typical pitfall of forgetting
that constant expressions exist, and they aren't free to invert,
because the `not` won't be absorbed by the "constant",
but will remain a (constant) expression...
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
llvm/test/Transforms/InstCombine/not-add.ll