Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::CTTZ , MVT::i32 , Custom);
setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::i32 , Legal);
if (Subtarget.is64Bit()) {
setOperationPromotedToType(ISD::CTTZ , MVT::i32, MVT::i64);
setOperationAction(ISD::CTTZ , MVT::i64 , Custom);
setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::i64, Legal);
}
Expand Down Expand Up @@ -3238,10 +3237,9 @@ bool X86TargetLowering::shouldFormOverflowOp(unsigned Opcode, EVT VT,
}

bool X86TargetLowering::isCheapToSpeculateCttz(Type *Ty) const {
// Speculate cttz only if we can directly use TZCNT or can promote to i32/i64.
// Speculate cttz only if we can directly use TZCNT or can promote to i32.
return Subtarget.hasBMI() ||
(!Ty->isVectorTy() &&
Ty->getScalarSizeInBits() < (Subtarget.is64Bit() ? 64u : 32u));
(!Ty->isVectorTy() && Ty->getScalarSizeInBits() < 32);
}

bool X86TargetLowering::isCheapToSpeculateCtlz(Type *Ty) const {
Expand Down
12 changes: 7 additions & 5 deletions llvm/test/CodeGen/X86/cttz.ll
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,13 @@ define i32 @cttz_i32_zero_test(i32 %n) {
;
; X64-LABEL: cttz_i32_zero_test:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
; X64-NEXT: movabsq $4294967296, %rax # imm = 0x100000000
; X64-NEXT: orq %rdi, %rax
; X64-NEXT: rep bsfq %rax, %rax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: testl %edi, %edi
; X64-NEXT: je .LBB6_1
; X64-NEXT: # %bb.2: # %cond.false
; X64-NEXT: rep bsfl %edi, %eax
; X64-NEXT: retq
; X64-NEXT: .LBB6_1:
; X64-NEXT: movl $32, %eax
; X64-NEXT: retq
;
; X86-CLZ-LABEL: cttz_i32_zero_test:
Expand Down
Loading