[llvm] r370460 - [DAGCombine] visitMULHS/visitMULHU - isBuildVectorAllZeros doesn't mean node is all zeros
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 03:42:14 PDT 2019
Author: rksimon
Date: Fri Aug 30 03:42:14 2019
New Revision: 370460
URL: http://llvm.org/viewvc/llvm-project?rev=370460&view=rev
Log:
[DAGCombine] visitMULHS/visitMULHU - isBuildVectorAllZeros doesn't mean node is all zeros
Return a proper zero vector, just in case some elements are undef.
Noticed by inspection after dealing with a similar issue in PR43159.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=370460&r1=370459&r2=370460&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Aug 30 03:42:14 2019
@@ -4183,10 +4183,10 @@ SDValue DAGCombiner::visitMULHS(SDNode *
if (VT.isVector()) {
// fold (mulhs x, 0) -> 0
- if (ISD::isBuildVectorAllZeros(N1.getNode()))
- return N1;
- if (ISD::isBuildVectorAllZeros(N0.getNode()))
- return N0;
+ // do not return N0/N1, because undef node may exist.
+ if (ISD::isBuildVectorAllZeros(N0.getNode()) ||
+ ISD::isBuildVectorAllZeros(N1.getNode()))
+ return DAG.getConstant(0, DL, VT);
}
// fold (mulhs x, 0) -> 0
@@ -4230,10 +4230,10 @@ SDValue DAGCombiner::visitMULHU(SDNode *
if (VT.isVector()) {
// fold (mulhu x, 0) -> 0
- if (ISD::isBuildVectorAllZeros(N1.getNode()))
- return N1;
- if (ISD::isBuildVectorAllZeros(N0.getNode()))
- return N0;
+ // do not return N0/N1, because undef node may exist.
+ if (ISD::isBuildVectorAllZeros(N0.getNode()) ||
+ ISD::isBuildVectorAllZeros(N1.getNode()))
+ return DAG.getConstant(0, DL, VT);
}
// fold (mulhu x, 0) -> 0
More information about the llvm-commits
mailing list