Skip to content

Commit 29b2009

Browse files
committed
Revert "[DAG] SimplifyDemandedBits - if we're only demanding the signbit, a SMIN/SMAX node can be simplified to a OR/AND node respectively."
This reverts commit 54d663d, which breaks the test CodeGen/SystemZ/ctpop-01.ll for stage2-ubsan check (see https://lab.llvm.org/buildbot/#/builders/85/builds/18410) I manually confirmed that the test had been passing immediately prior to that commit (BUILDBOT_REVISION=4772c66cfb00d60f8f687930e9dd3aa1b6872228 llvm-zorg/zorg/buildbot/builders/sanitizers/buildbot_bootstrap_ubsan.sh)
1 parent 548789b commit 29b2009

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,22 +1688,6 @@ bool TargetLowering::SimplifyDemandedBits(
16881688
Known.Zero.setBitsFrom(1);
16891689
break;
16901690
}
1691-
case ISD::SMIN: {
1692-
SDValue Op0 = Op.getOperand(0);
1693-
SDValue Op1 = Op.getOperand(1);
1694-
// If we're only wanting the signbit, then we can simplify to OR node.
1695-
if (OriginalDemandedBits.isSignMask())
1696-
return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::OR, dl, VT, Op0, Op1));
1697-
break;
1698-
}
1699-
case ISD::SMAX: {
1700-
SDValue Op0 = Op.getOperand(0);
1701-
SDValue Op1 = Op.getOperand(1);
1702-
// If we're only wanting the signbit, then we can simplify to AND node.
1703-
if (OriginalDemandedBits.isSignMask())
1704-
return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::AND, dl, VT, Op0, Op1));
1705-
break;
1706-
}
17071691
case ISD::SHL: {
17081692
SDValue Op0 = Op.getOperand(0);
17091693
SDValue Op1 = Op.getOperand(1);

llvm/test/CodeGen/X86/smax.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,9 @@ define i64 @test_signbits_i64(i64 %a, i64 %b) nounwind {
692692
; X86-LABEL: test_signbits_i64:
693693
; X86: # %bb.0:
694694
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
695-
; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
695+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
696+
; X86-NEXT: cmpl %eax, %ecx
697+
; X86-NEXT: cmovgl %ecx, %eax
696698
; X86-NEXT: movl %eax, %edx
697699
; X86-NEXT: sarl $31, %edx
698700
; X86-NEXT: retl
@@ -707,7 +709,8 @@ define i128 @test_signbits_i128(i128 %a, i128 %b) nounwind {
707709
; X64: # %bb.0:
708710
; X64-NEXT: movq %rcx, %rax
709711
; X64-NEXT: sarq $28, %rax
710-
; X64-NEXT: andq %rsi, %rax
712+
; X64-NEXT: cmpq %rax, %rsi
713+
; X64-NEXT: cmovgq %rsi, %rax
711714
; X64-NEXT: movq %rax, %rdx
712715
; X64-NEXT: sarq $63, %rdx
713716
; X64-NEXT: retq

llvm/test/CodeGen/X86/smin.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,9 @@ define i64 @test_signbits_i64(i64 %a, i64 %b) nounwind {
693693
; X86-LABEL: test_signbits_i64:
694694
; X86: # %bb.0:
695695
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
696-
; X86-NEXT: orl {{[0-9]+}}(%esp), %eax
696+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
697+
; X86-NEXT: cmpl %eax, %ecx
698+
; X86-NEXT: cmovll %ecx, %eax
697699
; X86-NEXT: movl %eax, %edx
698700
; X86-NEXT: sarl $31, %edx
699701
; X86-NEXT: retl
@@ -708,7 +710,8 @@ define i128 @test_signbits_i128(i128 %a, i128 %b) nounwind {
708710
; X64: # %bb.0:
709711
; X64-NEXT: movq %rcx, %rax
710712
; X64-NEXT: sarq $28, %rax
711-
; X64-NEXT: orq %rsi, %rax
713+
; X64-NEXT: cmpq %rax, %rsi
714+
; X64-NEXT: cmovlq %rsi, %rax
712715
; X64-NEXT: movq %rax, %rdx
713716
; X64-NEXT: sarq $63, %rdx
714717
; X64-NEXT: retq

0 commit comments

Comments
 (0)