21 Commits

Author SHA1 Message Date
Sanjay Patel
20167e8483 [InstSimplify] !(X && Y) || X --> true (for poison-safe logical ops)
https://alive2.llvm.org/ce/z/xuvL46

This is the similar to the existing folds added with:
D138853 / f2973327496fc966c4e89597
7dbeb127eaf6
...but with the and/or swapped.
2023-01-29 10:24:52 -05:00
Sanjay Patel
081a4e6712 [InstSimplify] add tests for poison-safe logical nand+or; NFC 2023-01-29 09:43:53 -05:00
Sanjay Patel
7dbeb127ea [InstSimplify] X && !(X || Y) --> false
https://alive2.llvm.org/ce/z/7J8Exr

This is a commuted variant that was not included in:
D138853 / f2973327496fc966c4e89597
2023-01-26 13:38:43 -05:00
Sanjay Patel
a56a02bc7e [InstSimplify] add commuted variants of logical and/or pattern; NFC
Existing tests were added with D138853, but that patch failed
to handle all of the commutes. The poison-safety behavior is
symmetric, so I'm not duplicating all of the tests that were
added with that patch.
2023-01-26 13:38:43 -05:00
Sanjay Patel
d178c15cac [InstSimplify] (X || Y) && Y --> Y (for poison-safe logical ops)
https://alive2.llvm.org/ce/z/oT_tEh

This is the conjugate/sibling pattern suggested in post-commit
feedback for:
9444252a674df5952bb5af2b76348ae4b45

issue #60167
2023-01-22 10:44:45 -05:00
Sanjay Patel
b9a6b4e3eb [InstSimplify] add tests for poison-safe variants of (X || Y) && Y; NFC 2023-01-22 10:44:44 -05:00
Sanjay Patel
9444252a67 [InstSimplify] with poison-safe logical ops: (X && Y) || X --> X
https://alive2.llvm.org/ce/z/ptZcJH

issue #60167
2023-01-20 17:35:24 -05:00
Sanjay Patel
5542bbf250 [InstSimplify] add tests for logical-and/or reduction; NFC
issue #60167
2023-01-20 17:35:24 -05:00
Sanjay Patel
6c232db2ae [InstSimplify] fold selects where true/false arm is the same as condition
We managed to fold related patterns in issue #59704,
but we were missing these more basic folds:
https://alive2.llvm.org/ce/z/y6d7SN
2022-12-30 08:54:09 -05:00
Sanjay Patel
94944f800c [InstSimplify] add tests for select-of-bool; NFC 2022-12-30 08:54:08 -05:00
Sanjay Patel
47f5da47f5 [InstSimplify] (X && Y) ? X : Y --> Y
Similar to the recent fold that was added for 'or' in D138815:
https://alive2.llvm.org/ce/z/PBapTJ
2022-11-30 15:44:48 -05:00
Sanjay Patel
d422f7e494 [InstSimplify] add tests for select with common 'and' ops; NFC 2022-11-30 15:44:48 -05:00
chenglin.bi
f297332749 [InstSimplify] Fold (X || Y) ? X : Y --> X
(X || Y) ? X : Y --> X
https://alive2.llvm.org/ce/z/oRQJee

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D138815
2022-11-30 10:14:17 +08:00
chenglin.bi
1fd4d91fa6 [InstSimplify] Fold !(X || Y) && X --> false
!(X || Y) && X --> false
https://alive2.llvm.org/ce/z/693Jgv

Fix: [56654](https://github.com/llvm/llvm-project/issues/56654)
Fix: [56780](https://github.com/llvm/llvm-project/issues/56780)

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D138853
2022-11-29 22:45:24 +08:00
chenglin.bi
0752fb57e4 [InstSimplify] Fold (X || Y) ? false : X --> false
(X || Y) ? false : X --> false
https://alive2.llvm.org/ce/z/y93yUm

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D138700
2022-11-29 22:08:50 +08:00
chenglin.bi
0869a96ca9 [InstSimplify] add precommit test for pattern !(X || Y) && X --> false; NFC 2022-11-29 04:07:43 +08:00
chenglin.bi
52dd5b6e95 [InstSimplify] add precommit test for pattern (X || Y) ? false : X -> false; NFC 2022-11-29 03:47:34 +08:00
chenglin.bi
617be4f37b [InstSimplify] Add precommit tests for select+or patterns; NFC 2022-11-28 22:58:39 +08: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
Sanjay Patel
fdbf2bb4ee [InstSimplify] (x || y) && (x || !y) --> x
https://alive2.llvm.org/ce/z/4BE33w

This is the logical (select-form) equivalent of the bitwise logic fold:
e36d351d19b1

This is another part of solving the regression from:
https://llvm.org/PR52077
2021-10-07 12:25:25 -04:00
Sanjay Patel
5ae6df1fea [InstSimplify] add tests for (x || y) && (x || !y); NFC 2021-10-07 10:37:34 -04:00