diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-10-06 02:50:24 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-10-06 02:50:24 +0000 |
commit | 79dd1bf09441fc62e959c08d7146d94b282691ba (patch) | |
tree | d02e0a569da651ca21f32171c405de3ebfa95d61 /llvm/lib/Target/X86/X86TargetTransformInfo.cpp | |
parent | d69d4953336c0e07cc875235de0d1c323b53d764 (diff) | |
download | bcm5719-llvm-79dd1bf09441fc62e959c08d7146d94b282691ba.tar.gz bcm5719-llvm-79dd1bf09441fc62e959c08d7146d94b282691ba.zip |
[X86] Teach constant hoisting that ANDs with 64-bit immediates in the range 0x80000000-0xffffffff can be handled cheaply and don't need to be hoisted.
Most importantly, this keeps constant hoisting from preventing instruction selections ability to turn an AND with 0xffffffff into a move into a 32-bit subregister.
llvm-svn: 249370
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetTransformInfo.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index f23057083f9..7f1db70d614 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -1078,6 +1078,13 @@ int X86TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, case Instruction::Store: ImmIdx = 0; break; + case Instruction::And: + // We support 64-bit ANDs with immediates with 32-bits of leading zeroes + // by using a 32-bit operation with implicit zero extension. Detect such + // immediates here as the normal path expects bit 31 to be sign extended. + if (Idx == 1 && Imm.getBitWidth() == 64 && isUInt<32>(Imm.getZExtValue())) + return TTI::TCC_Free; + // Fallthrough case Instruction::Add: case Instruction::Sub: case Instruction::Mul: @@ -1085,7 +1092,6 @@ int X86TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, case Instruction::SDiv: case Instruction::URem: case Instruction::SRem: - case Instruction::And: case Instruction::Or: case Instruction::Xor: case Instruction::ICmp: |