From 0113638073ffe734a5fe4ffa1d534c9e044fcb06 Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Thu, 18 Nov 2004 04:56:53 +0000 Subject: [PATCH] Clean up and fix cast codegen by removing cases that are handled elsewhere, and properly emitting signed short to unsigned int. This fixes the last regression vs. the CBE, MultiSource/Applications/hbd. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17942 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPC32ISelSimple.cpp | 27 ++++++++------------------ 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp index 0e8b7b04c56..2485bcbbebc 100644 --- a/lib/Target/PowerPC/PPC32ISelSimple.cpp +++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp @@ -3561,16 +3561,11 @@ void PPC32ISel::emitCastOperation(MachineBasicBlock *MBB, // handle { byte, short, int } x { byte, short, int } switch (SrcClass) { case cByte: - if (DestClass == cByte) - BuildMI(*MBB, IP, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg); - else - BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); + BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); break; case cShort: if (DestClass == cByte) BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); - else if (DestClass == cShort) - BuildMI(*MBB, IP, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg); else BuildMI(*MBB, IP, PPC::EXTSH, 1, DestReg).addReg(SrcReg); break; @@ -3608,19 +3603,13 @@ void PPC32ISel::emitCastOperation(MachineBasicBlock *MBB, // handle u{ byte, short, int } -> { byte, short, int } switch (SrcClass) { case cByte: - if (DestClass == cByte) - // uByte 255 -> signed byte == -1 - BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); - else - // uByte 255 -> signed short/int == 255 - BuildMI(*MBB, IP, PPC::RLWINM, 4, DestReg).addReg(SrcReg).addImm(0) - .addImm(24).addImm(31); + // uByte 255 -> signed short/int == 255 + BuildMI(*MBB, IP, PPC::RLWINM, 4, DestReg).addReg(SrcReg).addImm(0) + .addImm(24).addImm(31); break; case cShort: if (DestClass == cByte) BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); - else if (DestClass == cShort) - BuildMI(*MBB, IP, PPC::EXTSH, 1, DestReg).addReg(SrcReg); else BuildMI(*MBB, IP, PPC::RLWINM, 4, DestReg).addReg(SrcReg).addImm(0) .addImm(16).addImm(31); @@ -3660,14 +3649,14 @@ void PPC32ISel::emitCastOperation(MachineBasicBlock *MBB, unsigned clearBits = (DestClass == cByte) ? 24 : 16; switch (SrcClass) { case cByte: + BuildMI(*MBB, IP, PPC::EXTSB, 1, DestReg).addReg(SrcReg); + break; case cShort: - if (DestClass == cByte || DestClass == cShort) - // sbyte -1 -> ubyte 0x000000FF + if (DestClass == cByte) BuildMI(*MBB, IP, PPC::RLWINM, 4, DestReg).addReg(SrcReg) .addImm(0).addImm(clearBits).addImm(31); else - // sbyte -1 -> ubyte 0xFFFFFFFF - BuildMI(*MBB, IP, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg); + BuildMI(*MBB, IP, PPC::EXTSH, 1, DestReg).addReg(SrcReg); break; case cLong: ++SrcReg;