Skip to content

Commit 8725b67

Browse files
committed
[DAG] expandABS - add missing FREEZE in abs(x) -> smax(x,sub(0,x)) expansion
Noticed while working on #94601
1 parent e040474 commit 8725b67

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9159,6 +9159,7 @@ SDValue TargetLowering::expandABS(SDNode *N, SelectionDAG &DAG,
91599159
if (!IsNegative && isOperationLegal(ISD::SUB, VT) &&
91609160
isOperationLegal(ISD::SMAX, VT)) {
91619161
SDValue Zero = DAG.getConstant(0, dl, VT);
9162+
Op = DAG.getFreeze(Op);
91629163
return DAG.getNode(ISD::SMAX, dl, VT, Op,
91639164
DAG.getNode(ISD::SUB, dl, VT, Zero, Op));
91649165
}
@@ -9175,8 +9176,8 @@ SDValue TargetLowering::expandABS(SDNode *N, SelectionDAG &DAG,
91759176
// 0 - abs(x) -> smin(x, sub(0,x))
91769177
if (IsNegative && isOperationLegal(ISD::SUB, VT) &&
91779178
isOperationLegal(ISD::SMIN, VT)) {
9178-
Op = DAG.getFreeze(Op);
91799179
SDValue Zero = DAG.getConstant(0, dl, VT);
9180+
Op = DAG.getFreeze(Op);
91809181
return DAG.getNode(ISD::SMIN, dl, VT, Op,
91819182
DAG.getNode(ISD::SUB, dl, VT, Zero, Op));
91829183
}

0 commit comments

Comments
 (0)