710 Commits

Author SHA1 Message Date
Matt Arsenault
bdf428af98 ValueTracking: Consider demanded elts for vector constants in computeKnownFPClass 2024-04-08 09:32:14 -04:00
Matt Arsenault
2bc637b1ce ValueTracking: Handle ConstantAggregateZero in computeKnownFPClass 2024-04-08 09:26:12 -04:00
Matt Arsenault
0832b85e0f ValueTracking: Add baseline tests for vector fpclass handling 2024-04-08 09:26:12 -04:00
Noah Goldstein
e4db938a4e [ValueTracking] Support non-constant idx for computeKnownFPClass of insertelement
Its same logic as before, we just need to intersect what we know about
the new Elt and the entire pre-existing Vec.

Closes #87708
2024-04-06 17:51:15 -05:00
Noah Goldstein
d5b48ceb74 [ValueTracking] Add tests for non-constant idx for fpclass of insertelement; NFC 2024-04-06 17:51:15 -05:00
Matt Arsenault
733640d29e
Attributor: Handle inferring align from use by atomics (#85762) 2024-03-21 10:54:03 +05:30
Matt Arsenault
1a6953a75d ValueTracking: Fix bug with fcmp false to nan constant
If we had a comparison to a literal nan with a false predicate,
we were incorrectly treating it as an unordered compare. This was
correct for fcmp true, but not fcmp false. I noticed this in the
review for e44d3b3e503fa12fdaead2936b28844aa36237c1 but misdiagnosed
the reason. Also change the test for the fcmp true case to be more
useful, but it wasn't wrong previously.
2024-03-19 14:52:45 +05:30
Stephen Tozer
2e39b57837 Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)"
This reapplication changes debug intrinsic declaration removal to only take
place when printing final IR, so that the processing format of the Module
does not affect the output.

This reverts commit d128448efdd4e2bf3c9bc9a5b43ae642aa78026f.
2024-02-27 14:23:52 +00:00
Stephen Tozer
d128448efd Revert "Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)""
Reverted due to some test failures on some buildbots.

https://lab.llvm.org/buildbot/#/builders/67/builds/14669

This reverts commit aa436493ab7ad4cf323b0189c15c59ac9dc293c7.
2024-02-27 10:17:24 +00:00
Stephen Tozer
aa436493ab Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)"
Fixes the prior issue in which the symbol for a cl-arg was unavailable to
some binaries.

This reverts commit dc06d75ab27b4dcae2940fc386fadd06f70faffe.
2024-02-27 09:59:08 +00:00
Stephen Tozer
dc06d75ab2 Revert "[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)"
Reverted due to failures on buildbots, where a new cl flag was placed
in the wrong file, resulting in link errors.

https://lab.llvm.org/buildbot/#/builders/198/builds/8548

This reverts commit 0b398256b3f72204ad1f7c625efe4990204e898a.
2024-02-26 18:49:18 +00:00
Stephen Tozer
0b398256b3
[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)
This patch adds support for printing the proposed non-instruction debug
info ("RemoveDIs") out to textual IR. This patch does not add any
bitcode support, parsing support, or documentation.

Printing of the new format is controlled by a flag added in this patch,
`--write-experimental-debuginfo`, which defaults to false. The new
format will be printed *iff* this flag is true, so whether we use the IR
format is completely independent of whether we use non-instruction debug
info during LLVM passes (which is controlled by the
`--try-experimental-debuginfo-iterators` flag).

Even with the flag disabled, some existing tests need to be updated, as this
patch causes debug intrinsic declarations to be changed in a round trip,
such that they always appear at the end of a module and have no attributes
(this has no functional change on the module).

The design of this new IR format was proposed previously on
Discourse, and any further discussion about the design can still be
contributed there:

https://discourse.llvm.org/t/rfc-debuginfo-proposed-changes-to-the-textual-ir-representation-for-debug-values/73491
2024-02-26 18:22:05 +00:00
Yingwei Zheng
a5865c3c3d
[ValueTracking] Fix computeKnownFPClass for fpext (#81972)
This patch adds the missing `subnormal -> normal` part for `fpext` in
`computeKnownFPClass`.
Fixes the miscompilation reported by
https://github.com/llvm/llvm-project/pull/80941#issuecomment-1947302100.
2024-02-17 23:30:45 +08:00
Jeremy Morse
89ad31fd93
[RemoveDIs][DebugInfo] Perform some pre-turn-on test maintenence (#80885)
As we'll hopefully move away from using intrinsics for debug-info
shortly, this commit stabilizes a few tests to avoid spurious changes in
the process. Briefly, there are differences in output when we don't use
intrinsics that we're going to suppress in case we have to revert, these
are:
* The attributor test gets different attributes for the dbg.value
intrinsic because it's not present during optimisation. This has no
functional effect and there's no need to test for it.
* The Scalarizer test exposes a "debug-info affects codegen" problem,
but fixing it is fiddly (updating 20 IRBuilder object calls). Pin this
test to not change with RemoveDIs, we can relax it later and get the
correct behaviour.
* DIDefaultTemplateParam.ll tests for explicit metadata node numbers
which is generally bad. Add explicit node-number capturing CHECK lines.
2024-02-07 11:13:24 +00:00
Nikita Popov
2d69827c5c [Transforms] Convert tests to opaque pointers (NFC) 2024-02-05 11:57:34 +01:00
Matt Arsenault
e44d3b3e50
ValueTracking: Merge fcmpImpliesClass and fcmpToClassTest (#66522)
Rushing this one out before vacation starts. Refactoring on top of
#66505
2024-01-27 08:44:36 +05:30
Matt Arsenault
a46422a776 Reapply "ValueTracking: Identify implied fp classes by general fcmp (#66505)"
This reverts commit 0d0c2298552222b049fa3b8db5efef4b161e51e9.

Includes a bug fix for fcmp one handling, as well as for positive constants.
2024-01-25 13:38:23 +05:30
Matt Arsenault
f7a615a7d5 ValueTracking: Use correct compare type in test 2024-01-25 12:54:47 +05:30
Jeremy Morse
0065d06760
[NFC][DebugInfo] Maintain RemoveDIs flag when attributor creates functions (#79143)
We're using this flag (IsNewDbgInfoFormat) to detect the boundaries in
LLVM of what's treating debug-info as intrinsics (i.e. dbg.value), and
what's using DPValue objects (the non-intrinsic replacement). The
attributor tends to create new wrapper functions and doesn't insert them
into Modules in the usual way, thus we have to manually update that flag
to signal what debug-info mode it's using.

I've added some --try-experimental-debuginfo-iterators RUN lines to
tests that would otherwise crash because of this, so that they're
exercised by our new-debuginfo-iterators buildbot.

NB: there's an attributor test with a dbg.value in it, however
attributes re-order themselves in RemoveDIs mode for various reasons, so
we're going to address that in a different patch.
2024-01-24 15:20:05 +00:00
Matt Arsenault
55f12299d8
ValueTracking: Recognize fcmp ole/ugt with inf as a class test (#79095)
These were missed and hopefully avoids assertions when
dc3faf0ed0e3f1ea9e435a006167d9649f865da1 is recommitted.
2024-01-23 20:20:40 +07:00
Matt Arsenault
8076b89695 ValueTracking: Handle fcmp true/false in fcmpToClassTest
This ensures full compare coverage for certain special constants.
2024-01-23 12:10:45 +07:00
Matt Arsenault
1a99df9f3d ValueTracking: Add tests for fcmpToClassTest for fcmp ole/ugt inf
This catches an assertion in a recommit of
dc3faf0ed0e3f1ea9e435a006167d9649f865da1
2024-01-23 12:10:40 +07:00
Matt Arsenault
35ab0c78cf ValueTracking: Add tests fcmpToClassTest for fcmp true/false 2024-01-23 12:10:31 +07:00
Nikita Popov
658b260dbf [Attributor] Don't construct pretty GEPs
Bring this in line with other transforms like ArgPromotion/SROA/
SCEVExpander and always produce canonical i8 GEPs.
2023-12-22 16:48:13 +01:00
Mikhail Goncharov
0d0c229855 Revert "Reapply "ValueTracking: Identify implied fp classes by general fcmp (#66505)""
This reverts commit d55692d60d218f402ce107520daabed15f2d9ef6.

See discussion in #66505: assertion fires in OSS build of TensorFlow.
2023-12-05 11:10:24 +01:00
Matt Arsenault
d55692d60d Reapply "ValueTracking: Identify implied fp classes by general fcmp (#66505)"
This reverts commit 96a0d714d58e48c363ee6abbbcdfd7a6ce646ac1.

Avoid assert with dynamic denormal-fp-math We don't recognize compares
with 0 as an exact class test if we don't know the denormal mode. We could
try to do better here, but it's probably not worth it.

Fixes asserts reported after 1adce7d8e47e2438f99f91607760b825e5e3cc37
2023-12-01 17:51:46 +09:00
Vidhush Singhal
754b93e466
[Attributor] New attribute to identify what byte ranges are alive for an allocation (#66148)
Changes the size of allocations automatically.
For now, implements the case when a single range from start of the
allocation is alive and the allocation can be reduced.
2023-11-10 16:26:37 -08:00
Hans Wennborg
96a0d714d5 Revert "ValueTracking: Identify implied fp classes by general fcmp (#66505)"
This causes asserts to fire:

  llvm/lib/Analysis/ValueTracking.cpp:4262:
  std::tuple<Value *, FPClassTest, FPClassTest> llvm::fcmpImpliesClass(CmpInst::Predicate, const Function &, Value *, const APFloat *, bool):
  Assertion `(RHSClass == fcPosNormal || RHSClass == fcNegNormal || RHSClass == fcPosSubnormal || RHSClass == fcNegSubnormal) && "should have been recognized as an exact class test"' failed.

See comments on the PR.

> Previously we could recognize exact class tests performed by
> an fcmp with special values (0s, infs and smallest normal).
> Expand this to recognize the implied classes by a compare with a general
> constant. e.g. fcmp ogt x, 1 implies positive and non-0.
>
> The API should be better merged with fcmpToClassTest but that
> made the diff way bigger, will try to do that in a future
> patch.

This reverts commit dc3faf0ed0e3f1ea9e435a006167d9649f865da1.
2023-11-10 14:45:52 +01:00
Matt Arsenault
dc3faf0ed0
ValueTracking: Identify implied fp classes by general fcmp (#66505)
Previously we could recognize exact class tests performed by
an fcmp with special values (0s, infs and smallest normal).
Expand this to recognize the implied classes by a compare with a general
constant. e.g. fcmp ogt x, 1 implies positive and non-0.
    
The API should be better merged with fcmpToClassTest but that
made the diff way bigger, will try to do that in a future
patch.
2023-11-10 11:39:19 +09:00
Johannes Doerfert
ba87fba806 [Attributor] Ignore different kernels for kernel lifetime objects
If a potential interfering access is in a different kernel and the
underlying object has kernel lifetime we can straight out ignore the
interfering access.
TODO: This should be made much stronger via "reaching kernels", which we
already track in AAKernelInfo.
2023-10-21 12:31:06 -07:00
Johannes Doerfert
bb96093ca6 [Attributor][NFC] Precommit test 2023-10-21 12:31:06 -07:00
Johannes Doerfert
499fb1b8d8 [Attributor][FIX] Interposable constants cannot be propagated 2023-10-20 19:28:09 -07:00
Nikita Popov
a3bbab1852
[IR] Don't mark experimental.guard as willreturn (#69433)
Control flow does not necessary continue past guard intrinsics, so don't
mark them as willreturn.

This fixes the miscompile in the sdiv-guard.ll test.
2023-10-19 09:01:48 +02:00
Matt Arsenault
bad5893c30 Attributor: Fix not propagating nofpclass arguments through transitive callers
Fixes #64867
2023-10-05 06:03:40 -07:00
Matt Arsenault
75a3cc9c92 Attributor: Add a few nofpclass tests 2023-10-05 06:03:39 -07:00
Matt Arsenault
1b235b087b ValueTracking: Add baseline tests for fcmp with non-0/inf constants
Currently assumes only do anything for fcmps that perform an exact
class test.
2023-09-11 20:03:03 +03:00
Shilei Tian
499f691be1 Revert "Reapply "[Attributor] Enable AAAddressSpace for OpenMPOpt (#65544)"""
This reverts commit c5525a6e8fb7f7c2ce7126ac5b17aaff01ac407f.
AMD BB is not happy again.
2023-09-08 15:46:23 -04:00
Shilei Tian
c5525a6e8f Reapply "[Attributor] Enable AAAddressSpace for OpenMPOpt (#65544)""
This reverts commit e592c2dcf5b7d2da6c2564f5d9990aa34079bad4 that
reverts e91e3cf.
2023-09-08 15:39:16 -04:00
Shilei Tian
a501d06fcb
[Attributor] Only manifest pointer operand for StoreInst in AAAddressSpace (#65708)
`AAAddressSpace` currently only works for `LoadInst` and `StoreInst`
currently. For `StoreInst`, the corresponding use can be the pointer
operand, or value operand, or both. When it is used as value operand, it
can prevent `AMDGPUPromoteAlloca` from optimization in certain cases.
This patch changes the manifest method such that only pointer operand
will be rewritten.
2023-09-08 15:24:25 -04:00
Johannes Doerfert
73a836a464
[Attributor] Look through indirect calls (#65197)
Through the new `Attributor::checkForAllCallees` we can look through
indirect calls and visit all potential callees if they are known. Most
AAs will do that implicitly now via `AACalleeToCallSite`, thus, most AAs
are able to deal with missing callees for call site IR positions.

Differential Revision: https://reviews.llvm.org/D112290
2023-09-08 12:14:38 -07:00
Matt Arsenault
ae542d979d ValueTracking: Add baseline test for fcmp implying classes 2023-09-07 20:30:15 +03:00
Shilei Tian
e592c2dcf5 Revert "[Attributor] Enable AAAddressSpace for OpenMPOpt (#65544)"
This reverts commit e91e3cf0748a80e1d7219c13fa6a7622321f4936 because
AMD BB is not happy with it.
2023-09-07 12:31:11 -04:00
Shilei Tian
e91e3cf074
[Attributor] Enable AAAddressSpace for OpenMPOpt (#65544) 2023-09-07 12:23:52 -04:00
Johannes Doerfert
06e6ec0d09 [Attributor][NFC] Precommit test 2023-09-01 22:14:38 -07:00
Matt Arsenault
301b0e477b ValueTracking: Handle exp10 in computeKnownFPClass
It's the same as the other exps.

https://reviews.llvm.org/D157891
2023-09-01 20:19:55 -04:00
Johannes Doerfert
37642714ed [Attributor][FIX] Support non-0 AS for function pointers 2023-09-01 17:17:51 -07:00
Johannes Doerfert
2544283597 [Core][FIX] Do not assume instruction users in DetermineUseCaptureKind 2023-09-01 17:17:51 -07:00
Matt Arsenault
af758d6531 ValueTracking: Add baseline test for exp10 computeKnownFPClass handling 2023-09-01 20:14:39 -04:00
Philip Reames
294ad08ecc Revert "Revert "InstSimplify: Use correct interested FP classes when simplifying fcmp""
This reverts commit 89f0314ee14a4d7f5a92fd63574ba545863df016.  Change does not build.
2023-09-01 12:17:36 -07:00
Zequan Wu
89f0314ee1 Revert "InstSimplify: Use correct interested FP classes when simplifying fcmp"
Revert "InstSimplify: Add baseline tests for reported regression"
Revert "InstSimplify: Start cleaning up simplifyFCmpInst"

This reverts commit 0637b00041c7d6a191d51d9966c4f5f41fb97ab5.
This reverts commit 239fb206de35935416e652b89725d5f3193f78f5.
This reverts commit ddb3f12c428bc4bd5a98913d74dfd7f2402bdfd8.

These commits causes crashes when compiling chromium code, attached reduced ir at: https://reviews.llvm.org/D151887#4634914
2023-09-01 14:54:27 -04:00