diff options
| author | Nate Begeman <natebegeman@mac.com> | 2004-10-23 00:50:23 +0000 | 
|---|---|---|
| committer | Nate Begeman <natebegeman@mac.com> | 2004-10-23 00:50:23 +0000 | 
| commit | 6cadac8f43bbe135ba1b6a69dc5c4018c1b3fe38 (patch) | |
| tree | 76b3bbb0f21959a5b115f7808904e8ddce2dd058 /llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp | |
| parent | 37a7102ccbc125177b186e2111986009828c8e72 (diff) | |
| download | bcm5719-llvm-6cadac8f43bbe135ba1b6a69dc5c4018c1b3fe38.tar.gz bcm5719-llvm-6cadac8f43bbe135ba1b6a69dc5c4018c1b3fe38.zip | |
Kill casts from integer types to unsigned byte, when the cast was only used
as the shift amount operand to a shift instruction.  This was causing us to
emit unnecessary clear operations for code such as:
int foo(int x) { return 1 << x; }
llvm-svn: 17175
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp | 13 | 
1 files changed, 13 insertions, 0 deletions
| diff --git a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp index 44d307d1187..f5a21f07c06 100644 --- a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp +++ b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp @@ -3014,6 +3014,19 @@ void PPC32ISel::visitCastInst(CastInst &CI) {    unsigned DestReg = getReg(CI);    MachineBasicBlock::iterator MI = BB->end(); +  // If this is a cast from an integer type to a ubyte, with one use where the +  // use is the shift amount argument of a shift instruction, just emit a move +  // instead (since the shift instruction will only look at the low 5 bits +  // regardless of how it is sign extended) +  if (CI.getType() == Type::UByteTy && SrcClass <= cInt && CI.hasOneUse()) { +    ShiftInst *SI = dyn_cast<ShiftInst>(*(CI.use_begin())); +    if (SI && (SI->getOperand(1) == &CI)) { +      unsigned SrcReg = getReg(Op, BB, MI); +      BuildMI(*BB, MI, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg); +      return;  +    } +  } +    // If this is a cast from an byte, short, or int to an integer type of equal    // or lesser width, and all uses of the cast are store instructions then dont    // emit them, as the store instruction will implicitly not store the zero or | 

