summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2018-10-11 23:14:35 +0000
committerMatthias Braun <matze@braunis.de>2018-10-11 23:14:35 +0000
commitd6131c9633d3ea05b6aa51a3a2d9df2ec328bd67 (patch)
tree2a4af9583b1b0eb737af3a715e49e43ecf0f83a6 /llvm/lib
parentd891ac9794363641f919c9ca8a7f9e3726121baf (diff)
downloadbcm5719-llvm-d6131c9633d3ea05b6aa51a3a2d9df2ec328bd67.tar.gz
bcm5719-llvm-d6131c9633d3ea05b6aa51a3a2d9df2ec328bd67.zip
X86/TargetTransformInfo: Report div/rem constant immediate costs as TCC_Free
DIV/REM by constants should always be expanded into mul/shift/etc. patterns. Unfortunately the ConstantHoisting pass runs too early at a point where the pattern isn't expanded yet. However after ConstantHoisting hoisted some immediate the result may not expand anymore. Also the hoisting typically doesn't make sense because it operates on immediates that will change completely during the expansion. Report DIV/REM as TCC_Free so ConstantHoisting will not touch them. Differential Revision: https://reviews.llvm.org/D53174 llvm-svn: 344315
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86TargetTransformInfo.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 4c14715b758..d3a75123935 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -2342,11 +2342,15 @@ int X86TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
return TTI::TCC_Free;
ImmIdx = 1;
break;
- case Instruction::Mul:
case Instruction::UDiv:
case Instruction::SDiv:
case Instruction::URem:
case Instruction::SRem:
+ // Division by constant is typically expanded later into a different
+ // instruction sequence. This completely changes the constants.
+ // Report them as "free" to stop ConstantHoist from marking them as opaque.
+ return TTI::TCC_Free;
+ case Instruction::Mul:
case Instruction::Or:
case Instruction::Xor:
ImmIdx = 1;
OpenPOWER on IntegriCloud