diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-07-30 17:29:57 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-07-30 17:29:57 +0000 |
| commit | dd0ef801f8b6a2c561337788d0a59e4bab3f4243 (patch) | |
| tree | 28d8aa873bb1940a5724d03ad949a366034a0f06 /llvm/lib/Target | |
| parent | bbcc8895bb8d476cb1006891f2e01e5fcfc9531d (diff) | |
| download | bcm5719-llvm-dd0ef801f8b6a2c561337788d0a59e4bab3f4243.tar.gz bcm5719-llvm-dd0ef801f8b6a2c561337788d0a59e4bab3f4243.zip | |
Recommit r338204 "[X86] Correct the immediate cost for 'add/sub i64 %x, 0x80000000'."
This checks in a more direct way without triggering a UBSAN error.
llvm-svn: 338273
Diffstat (limited to 'llvm/lib/Target')
| -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 1b260d8d45d..86546262262 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -2332,9 +2332,15 @@ int X86TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, // 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; - LLVM_FALLTHROUGH; + ImmIdx = 1; + break; case Instruction::Add: case Instruction::Sub: + // For add/sub, we can use the opposite instruction for INT32_MIN. + if (Idx == 1 && Imm.getBitWidth() == 64 && Imm.getZExtValue() == 0x80000000) + return TTI::TCC_Free; + ImmIdx = 1; + break; case Instruction::Mul: case Instruction::UDiv: case Instruction::SDiv: |

