-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SelectionDAG] Folding ZERO-EXTEND/SIGN_EXTEND poison to Poison value in getNode #122741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-aarch64 @llvm/pr-subscribers-backend-powerpc Author: zhijian lin (diggerlin) Changesin the function ```
|
✅ With the latest revision this PR passed the undef deprecator. |
Unfortunately, I think the IR semantics do not say that we can do this. For example: The result of sign-extending |
The issue that the effect of |
I think we would be able to do this for poison, but not undef. Unfortunately SelectionDAG turns poison into undef. |
thanks, I will take a look the pass |
The IR documentation does not appear to support this. It says
and
Any replacement of poison of the narrower type with a value (or I think the direction to take here is to see if the middle-end can change the function parameter to be |
My understanding is that (zext/sext undef) needs to produce a value where all the extended bits are 0 for zext or match the original sign bit for sext. According to InstCombine, (sext/zext poison) can constant fold to poison in the larger type. If SelectionDAG preserved the difference between poison and undef, it could also constant fold to poison. |
It sounds like you have more context than I do then. I believe that the description of |
There's a general statement in the Poison Values section. https://llvm.org/docs/LangRef.html#poison-values "Most instructions return ‘poison’ when one of their arguments is ‘poison’. A notable exception is the select instruction. Propagation of poison can be stopped with the freeze instruction." |
I added some printf into the in the line https://github.com/intel/llvm/blob/sycl/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp#L336, it converts the unused argument to the patch https://reviews.llvm.org/D125983 change the unused argument from but according to the https://releases.llvm.org/11.0.0/docs/LangRef.html#poison-values there is description as: There is currently no way of representing a poison value in the IR; they only exist when produced by operations such as add with the nsw flag. in the patch https://reviews.llvm.org/D125983, the poison can be represented a argument. does the document need to be modified? |
The "up-to-date" version of the document is here: https://llvm.org/docs/LangRef.html#poison-values. |
9bd90e7
to
4e80a92
Compare
li of 0 into arg registers
instruction of unused arguments
li of 0 into arg registers
instruction of unused arguments// FixMe: If the node represents a poison value, replace it with an undef | ||
// value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what is to be fixed here? The text seems to explain what the code is doing (not what it should do differently).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poison is more restrictive than undef. Since we replace poison with undef here, the poison information will be lost after SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) is called.
If we need to retain the poison information after SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) in the future, we will need to modify the code accordingly.
@@ -9237,6 +9263,11 @@ SDValue SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, | |||
|
|||
SDVTList VTs = Indexed ? | |||
getVTList(VT, Ptr.getValueType(), MVT::Other) : getVTList(VT, MVT::Other); | |||
|
|||
// FixedMe: lower poison to undef. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. Also: I think the convention is FIXME
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title should be about introducing poison to the DAG, not something about arguments I don't understand
This PR as-is is not about introducing poison to the DAG (that's the how, not the what). The actual operative change is the handling of poison for the width extensions.
Would "Introduce poison to the DAG; address signed/zero extend of poison" work?
These should not be mixed in. Introducing poison should be separate from any of this other stuff |
Reproducing @diggerlin's response to #122741 (comment):
|
5d02652
to
1202242
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/155/builds/8559 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/9384 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/208/builds/538 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/125/builds/7040 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/10191 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/202/builds/808 Here is the relevant piece of the build log for the reference
|
It looks like this broke check-llvm everywhere. I've reverted it for now. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/8921 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/7135 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/198/builds/3867 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/85/builds/7898 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/24/builds/7600 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/164/builds/9222 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/6502 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/94/builds/6413 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/199/builds/2914 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/6354 Here is the relevant piece of the build log for the reference
|
I created a patch #136636 to fix the test cases which cause the buildbot fail |
… in getNode (llvm#122741) The PR will fix the issue llvm#122728 This patch addresses the signed/zero extension of poison by using a poison value of the extended type instead of a constant zero of the extended type.
…son to Poison value in getNode (#122741)" This reverts commit f12078e. Breaks `check-llvm`, see comments on llvm/llvm-project#122741
… in getNode (llvm#122741) The PR will fix the issue llvm#122728 This patch addresses the signed/zero extension of poison by using a poison value of the extended type instead of a constant zero of the extended type.
…on value in getNode (llvm#122741)" This reverts commit f12078e. Breaks `check-llvm`, see comments on llvm#122741
… in getNode (llvm#122741) The PR will fix the issue llvm#122728 This patch addresses the signed/zero extension of poison by using a poison value of the extended type instead of a constant zero of the extended type.
…on value in getNode (llvm#122741)" This reverts commit f12078e. Breaks `check-llvm`, see comments on llvm#122741
… in getNode (llvm#122741) The PR will fix the issue llvm#122728 This patch addresses the signed/zero extension of poison by using a poison value of the extended type instead of a constant zero of the extended type.
…on value in getNode (llvm#122741)" This reverts commit f12078e. Breaks `check-llvm`, see comments on llvm#122741
The PR will fix the issue #122728
This patch addresses the signed/zero extension of poison by using a poison value of the extended type instead of a constant zero of the extended type.