aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PowerPC/PPCISelLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-19 05:22:59 +0000
committerChris Lattner <sabre@nondot.org>2006-09-19 05:22:59 +0000
commitcf9d0acfef1503439c231f2717b3d4b3afce67e1 (patch)
tree75f5395f97f753c01b3a6a943110c58ffe689f41 /lib/Target/PowerPC/PPCISelLowering.cpp
parent863ac769b850d75a390bfdc20b62d7d120fb69a9 (diff)
downloadexternal_llvm-cf9d0acfef1503439c231f2717b3d4b3afce67e1.zip
external_llvm-cf9d0acfef1503439c231f2717b3d4b3afce67e1.tar.gz
external_llvm-cf9d0acfef1503439c231f2717b3d4b3afce67e1.tar.bz2
Fold the PPCISD shifts when presented with 0 inputs. This occurs for code
like: long long test(long long X, int Y) { return 1ULL << Y; } long long test2(long long X, int Y) { return -1LL << Y; } which we used to compile to: _test: li r2, 1 subfic r3, r5, 32 li r4, 0 addi r6, r5, -32 srw r3, r2, r3 slw r4, r4, r5 slw r6, r2, r6 or r3, r4, r3 slw r4, r2, r5 or r3, r3, r6 blr _test2: li r2, -1 subfic r3, r5, 32 addi r6, r5, -32 srw r3, r2, r3 slw r4, r2, r5 slw r2, r2, r6 or r3, r4, r3 or r3, r3, r2 blr Now we produce: _test: li r2, 1 addi r3, r5, -32 subfic r4, r5, 32 slw r3, r2, r3 srw r4, r2, r4 or r3, r4, r3 slw r4, r2, r5 blr _test2: li r2, -1 subfic r3, r5, 32 addi r6, r5, -32 srw r3, r2, r3 slw r4, r2, r5 slw r2, r2, r6 or r3, r4, r3 or r3, r3, r2 blr git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30479 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCISelLowering.cpp')
-rw-r--r--lib/Target/PowerPC/PPCISelLowering.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index db33f5f..63ae9e7 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -2309,6 +2309,26 @@ SDOperand PPCTargetLowering::PerformDAGCombine(SDNode *N,
SelectionDAG &DAG = DCI.DAG;
switch (N->getOpcode()) {
default: break;
+ case PPCISD::SHL:
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N->getOperand(0))) {
+ if (C->getValue() == 0) // 0 << V -> 0.
+ return N->getOperand(0);
+ }
+ break;
+ case PPCISD::SRL:
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N->getOperand(0))) {
+ if (C->getValue() == 0) // 0 >>u V -> 0.
+ return N->getOperand(0);
+ }
+ break;
+ case PPCISD::SRA:
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N->getOperand(0))) {
+ if (C->getValue() == 0 || // 0 >>s V -> 0.
+ C->isAllOnesValue()) // -1 >>s V -> -1.
+ return N->getOperand(0);
+ }
+ break;
+
case ISD::SINT_TO_FP:
if (TM.getSubtarget<PPCSubtarget>().has64BitSupport()) {
if (N->getOperand(0).getOpcode() == ISD::FP_TO_SINT) {