7 Commits

Author SHA1 Message Date
Nikita Popov
9ca2c309ab [InstSimplify] Fix poison safety in insertvalue fold
We can only fold insertvalue undef, (extractvalue x, n) to x
if x is not poison, otherwise we might be replacing undef with
poison (https://alive2.llvm.org/ce/z/fnw3c8). The insertvalue
poison case is always fine.

I didn't go to particularly large effort to preserve cases where
folding with undef is still legal (mainly when there is a chain of
multiple inserts that end up covering the whole aggregate),
because this shouldn't really occur in practice: We should always
be generating the insertvalue poison form when constructing
aggregates nowadays.

Differential Revision: https://reviews.llvm.org/D144106
2023-02-16 09:39:44 +01:00
Nikita Popov
22882c39df [InstSimplify] Add additional insertvalue into undef tests (NFC) 2023-02-15 16:34:55 +01:00
Nikita Popov
8a09875dd1 [InstSimplify] Do not remove insertvalue of undef into poison
We cannot remove an insertvalue of undef if it inserts into a
potentially poison value. The new implementation matches that of
insertelement.

See https://alive2.llvm.org/ce/z/pCcFsW for the previously
incorrect transform.
2022-12-08 11:35:59 +01:00
Nikita Popov
8992fce0e0 [InstSimplify] Fix check lines (NFC)
Accidentally used the wrong binary in the previous commit.
2022-12-08 11:22:49 +01:00
Nikita Popov
e161454d2e [InstSimplify] Add test for insertvalue of undef (NFC) 2022-12-08 11:16:46 +01:00
Bjorn Pettersson
b280ee1dd7 [test] Use -passes=instsimplify instead of -instsimplify in a number of tests. NFC
Another step moving away from the deprecated syntax of specifying
pass pipeline in opt.

Differential Revision: https://reviews.llvm.org/D119080
2022-02-07 14:26:58 +01:00
Juneyoung Lee
864dda5fd5 [InstSimplify] Add tests that fold instructions with poison operands (NFC) 2020-12-02 01:01:59 +09:00