llvm-6502/lib/Transforms/InstCombine
Benjamin Kramer 7d6eb5a018 InstCombine: Turn (zext A) udiv (zext B) into (zext (A udiv B)). Same for urem or constant B.
This obviously helps a lot if the division would be turned into a libcall
(think i64 udiv on i386), but div is also one of the few remaining instructions
on modern CPUs that become more expensive when the bitwidth gets bigger.

This also helps register pressure on i386 when dividing chars, divb needs
two 8-bit parts of a 16 bit register as input where divl uses two registers.

int foo(unsigned char a) { return a/10; }
int bar(unsigned char a, unsigned char b) { return a/b; }

compiles into (x86_64)
_foo:
  imull $205, %edi, %eax
  shrl  $11, %eax
  ret
_bar:
  movzbl        %dil, %eax
  divb  %sil, %al
  movzbl        %al, %eax
  ret

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130615 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-30 18:16:07 +00:00
..
CMakeLists.txt
InstCombine.h Stop trying to have instcombine preserve LCSSA form: this was not 2011-04-27 10:55:12 +00:00
InstCombineAddSub.cpp add is always integer, thanks to Frits for noticing this. 2011-02-17 20:55:29 +00:00
InstCombineAndOrXor.cpp We require threse bits to be zero, too. 2011-04-28 21:38:51 +00:00
InstCombineCalls.cpp Reapply r129401 with patch for clang. 2011-04-13 00:36:11 +00:00
InstCombineCasts.cpp While SimplifyDemandedBits constant folds this, we can't rely on it here. 2011-04-02 18:50:58 +00:00
InstCombineCompares.cpp Transform: "icmp eq (trunc (lshr(X, cst1)), cst" to "icmp (and X, mask), cst" 2011-04-26 20:18:20 +00:00
InstCombineLoadStoreAlloca.cpp Remove PHINode::reserveOperandSpace(). Instead, add a parameter to 2011-03-30 11:28:46 +00:00
InstCombineMulDivRem.cpp InstCombine: Turn (zext A) udiv (zext B) into (zext (A udiv B)). Same for urem or constant B. 2011-04-30 18:16:07 +00:00
InstCombinePHI.cpp Stop trying to have instcombine preserve LCSSA form: this was not 2011-04-27 10:55:12 +00:00
InstCombineSelect.cpp Remove tabs I accidentally added. 2011-03-28 17:48:26 +00:00
InstCombineShifts.cpp Balance parentheses. 2011-04-29 08:41:23 +00:00
InstCombineSimplifyDemanded.cpp PR9346: Prevent SimplifyDemandedBits from incorrectly introducing 2011-03-09 01:28:35 +00:00
InstCombineVectorOps.cpp Instcombile optimization: extractelement(cast) -> cast(extractelement) 2011-03-31 22:57:29 +00:00
InstCombineWorklist.h InstCombine: We know the number of items initially added to the worklist map, reserve space early to avoid rehashing. 2011-03-05 16:43:46 +00:00
InstructionCombining.cpp Stop trying to have instcombine preserve LCSSA form: this was not 2011-04-27 10:55:12 +00:00
Makefile