[llvm] [DAGCombiner] Ensure poison-generating flags are stripped in `freeze` op (PR #114582)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 2 01:28:53 PDT 2024


================
@@ -16151,6 +16151,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
                              SVN->getMask());
   } else {
     // NOTE: this strips poison generating flags.
+    N0->dropFlags(SDNodeFlags::PoisonGeneratingFlags);
----------------
dtcxzyw wrote:

I don't think it is a correct fix. The following `getNode` creates a new copy without flags. However, it is CSEed to N0 in `SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, ArrayRef<SDValue> Ops, const SDNodeFlags Flags)`.

We should intersect flags after CSE here:
https://github.com/llvm/llvm-project/blob/92daad2eac587cb0592de019cd5f6cbb7c42bb78/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L10527-L10528

I will post a fix later.


https://github.com/llvm/llvm-project/pull/114582


More information about the llvm-commits mailing list