Commit Graph

1202 Commits

Author SHA1 Message Date
Alex Richardson
968f2c77a8 Re-gernerate a test in preparation for D141060 2023-01-06 17:38:55 +00: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
f0faea5714 [InstSimplify] fold exact divide to poison if it is known to not divide evenly
This is related to the discussion in D140665. I was looking over the demanded
bits implementation in IR and noticed that we just bail out of a potential
fold if a udiv is exact:
82be8a1d2b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (L799)

Also, see tests added with 7f0c11509e.

Then, I saw that we could lose a fold to poison if we zap the exact with that
transform, so this patch tries to catch that as a preliminary step.

Alive2 proofs:
https://alive2.llvm.org/ce/z/zCjKM7
https://alive2.llvm.org/ce/z/-tz_RK (trailing zeros must be "less-than")
https://alive2.llvm.org/ce/z/c9CMsJ (general proof and specific example)

Differential Revision: https://reviews.llvm.org/D140733
2022-12-29 10:26:50 -05:00
Sanjay Patel
935a6525e4 [InstSimplify] add tests for div exact; NFC 2022-12-28 14:08:47 -05:00
Matt Arsenault
8f111ecd75 InstSimplify: Split isKnownNeverInfinity tests into separate file
This fixes an annoying assymmetry in the test organization. We have
known-never-nan.ll for dedicated isKnownNeverNaN handling tests, but
the isKnownNeverInfinity were in floating-point-compare.ll. Move the
more targeted tests into a separate file to match.
2022-12-22 09:38:14 -05:00
Matt Arsenault
876f3d6c91 ValueTracking: Add test for isKnownNeverInfinity for fptrunc 2022-12-22 09:38:14 -05:00
Matt Arsenault
94a703ecdc ValueTracking: Add test for fneg isKnownNeverNaN handling
This didn't have a negative test.
2022-12-22 09:38:14 -05:00
Matt Arsenault
2c52c811ee ValueTracking: Document some difficult isKnownNeverInfinity cases
Add a comment and some negative tests. I'd like to have test coverage
and explicit handling of all the math operations for clarity.
2022-12-20 13:22:22 -05:00
Matt Arsenault
407b18820c ValueTracking: Add tests for isKnownNeverInfinity for llvm.log* 2022-12-20 13:17:03 -05:00
Matt Arsenault
2bf17cc048 ValueTracking: Teach isKnownNeverInfinity about llvm.sin/llvm.cos 2022-12-20 13:17:03 -05:00
Matt Arsenault
6d125fee8c ValueTracking: Add isKnownNeverInfinity tests for sin/cos 2022-12-20 13:17:03 -05:00
Matt Arsenault
9a21475651 ValueTracking: Teach isKnownNeverInfinity about sqrt 2022-12-20 13:03:07 -05:00
Matt Arsenault
b5963ea088 ValueTracking: Add base test for isKnownNeverInfinity of sqrt 2022-12-20 13:03:07 -05:00
Matt Arsenault
41dd02e857 ValueTracking: Teach isKnownNeverInfinity about min/max functions 2022-12-20 12:52:59 -05:00
Matt Arsenault
ef550ce361 ValueTracking: Add tests for isKnownNeverInfinity for min/max intrinsics 2022-12-20 12:52:59 -05:00
Matt Arsenault
4e37d00b9d ValueTracking: Teach isKnownNeverInfinity about rounding intrinsics 2022-12-20 12:45:07 -05:00
Matt Arsenault
2bfe62ed6a ValueTracking: Add tests for isKnownNeverInfinity for rounding intrinsics 2022-12-20 12:45:07 -05:00
Matt Arsenault
6acf6661dd ConstantFolding: Ignore output denorm mode for canonicalize
Alive2 opt plugin is now happy with the test. Fixes issue 59245
2022-12-13 08:44:21 -05:00
Matt Arsenault
4fa54f8b81 ConstantFolding: Fix handling of canonicalize for ppc_fp128 0s 2022-12-13 08:44:20 -05:00
Sanjay Patel
9055661b95 [InstSimplify] try harder to propagate existing NaN values through FP folds
Any undef element in a vector would trigger the whole constant
to be replaced with a canonical NaN. This propagates each
element when possible.

issue #59122
2022-12-12 17:52:14 -05:00
Sanjay Patel
44c3c93eae [InstSimplify] add tests for vectors with NaN + partial undef; NFC
issue #59122
2022-12-12 17:52:14 -05:00
Bjorn Pettersson
3528e63d89 [test] Remove duplicate RUN lines in Transform tests 2022-12-08 11:47:16 +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
Roman Lebedev
5b4b842ffb [NFC] Port all InstSimplify tests to -passes= syntax 2022-12-08 02:38:45 +03:00
Matt Arsenault
7f4429c0e4 ValueTracking: Teach CannotBeOrderedLessThanZero about copysign 2022-12-06 09:01:39 -05:00
Matt Arsenault
dbca874faa ValueTracking: Teach CannotBeOrderedLessThanZero about trivial ops
Handle canonicalize and arithmetic.fence
2022-12-05 08:39:07 -05:00
Matt Arsenault
db0f258479 ValueTracking: Teach isKnownNeverNaN about arithmetic_fence 2022-12-05 08:39:07 -05:00
Matt Arsenault
dac496fb1f ValueTracking: Teach isKnownNeverInfinity about arithmetic.fence 2022-12-05 08:39:07 -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
chenglin.bi
b400dde473 [InstSimplify] Use dominate condtion to simplify instructions
Fix #56795

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D138542
2022-11-26 21:41:41 +08:00
chenglin.bi
79fd94e9e7 [InstSimplify] Add precommit test for D138542; NFC 2022-11-24 09:04:33 +08:00
Matt Arsenault
841a0edd03 ConstantFolding: Constant fold some canonicalizes
+/-0 is obviously foldable. Other non-special, non-subnormal
values are also probably OK. For denormal values, check
the calling function's denormal mode. For now, don't fold
denormals to the input for IEEE mode because as far as I know
the langref is still pretending LLVM's float isn't IEEE.

Also folds undef to 0, although NaN may make more sense. Skips
folding nans and infinities, although it should be OK to fold those
in a future change.
2022-11-18 10:35:19 -08:00
Matt Arsenault
d2bbe5a5ff InstSimplify: Add baseline tests for canonicalize 2022-11-18 08:53:50 -08:00
Matt Arsenault
af7e80b7cb ValueTracking: Look through copysign in isKnownNeverInfinity 2022-11-17 08:52:09 -08:00
Matt Arsenault
29e4363dda ValueTracking: Look through fneg in isKnownNeverNaN 2022-11-17 08:35:49 -08:00
Matt Arsenault
ba1669c81f ValueTracking: Look through fabs and fneg in isKnownNeverInfinity 2022-11-17 00:06:15 -08:00
Matt Arsenault
d24fe812ec ValueTracking: Look through canonicalize in isKnownNeverInfinity 2022-11-17 00:06:15 -08:00
Matt Arsenault
fde4ef1973 InstSimplify: Fold arithmetic_fence as idempotent 2022-11-15 22:29:34 -08:00
Sanjay Patel
0a37290dc8 [InstSimplify] restrict logic fold with partial undef vector
https://alive2.llvm.org/ce/z/4ncsnX

Fixes #58977
2022-11-14 12:09:23 -05:00
Sanjay Patel
c2c48f0c96 [InstSimplify] add test for fsub with inf operand; NFC
Verify that constant negation works with a partial undef vector.
Also, remove a bogus TODO comment on a related test.
2022-11-11 09:17:20 -05:00