Skip to content

Commit 8f7054c

Browse files
committed
Add freeze, ban vector
1 parent 0c20d33 commit 8f7054c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10878,7 +10878,8 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
1087810878
assert(VT.isInteger() && "Expected operands to be integers");
1087910879

1088010880
// usub.sat(a, 1) -> sub(a, zext(a != 0))
10881-
if (Opcode == ISD::USUBSAT && isOneConstant(RHS)) {
10881+
if (Opcode == ISD::USUBSAT && !VT.isVector() && isOneConstant(RHS)) {
10882+
LHS = DAG.getFreeze(LHS);
1088210883
SDValue Zero = DAG.getConstant(0, dl, VT);
1088310884
EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
1088410885
SDValue IsNonZero = DAG.getSetCC(dl, BoolVT, LHS, Zero, ISD::SETNE);

llvm/test/CodeGen/X86/combine-sub-usat.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ define <8 x i16> @combine_zero_v8i16(<8 x i16> %a0) {
116116
define i32 @combine_dec_i32(i32 %a0) {
117117
; CHECK-LABEL: combine_dec_i32:
118118
; CHECK: # %bb.0:
119-
; CHECK-NEXT: xorl %eax, %eax
120-
; CHECK-NEXT: subl $1, %edi
121-
; CHECK-NEXT: cmovael %edi, %eax
119+
; CHECK-NEXT: movl %edi, %eax
120+
; CHECK-NEXT: cmpl $1, %edi
121+
; CHECK-NEXT: adcl $-1, %eax
122122
; CHECK-NEXT: retq
123123
%1 = call i32 @llvm.usub.sat.i32(i32 %a0, i32 1)
124124
ret i32 %1

0 commit comments

Comments
 (0)