summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-01 19:38:28 +0000
committerChris Lattner <sabre@nondot.org>2005-09-01 19:38:28 +0000
commit293b3a68e00bedd8e3a675cb79813b751a48a962 (patch)
treeed9112883f4854d994e5babfbe9fc4769ab30c8a /llvm
parent34182aff7f5c57c5eec329347c9b6ee8ccee345d (diff)
downloadbcm5719-llvm-293b3a68e00bedd8e3a675cb79813b751a48a962.tar.gz
bcm5719-llvm-293b3a68e00bedd8e3a675cb79813b751a48a962.zip
Fix a bug where we were useing HA to get the high part, which seems like it
could cause a miscompile. Fixing this didn't fix the two programs that fail though. :( This also changes the implementation to follow the pattern selector more closely, causing us to select 0 to li instead of lis. llvm-svn: 23189
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index d8d07005983..c650c0f3082 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -685,22 +685,21 @@ SDOperand PPC32DAGToDAGISel::Select(SDOperand Op) {
case ISD::Constant: {
assert(N->getValueType(0) == MVT::i32);
unsigned v = (unsigned)cast<ConstantSDNode>(N)->getValue();
- unsigned Hi = HA16(v);
- unsigned Lo = Lo16(v);
// NOTE: This doesn't use SelectNodeTo, because doing that will prevent
// folding shared immediates into other the second instruction that
// uses it.
- if (Hi && Lo) {
- SDOperand Top = CurDAG->getTargetNode(PPC::LIS, MVT::i32,
- getI32Imm(v >> 16));
- return CurDAG->getTargetNode(PPC::ORI, MVT::i32, Top,
- getI32Imm(v & 0xFFFF));
- } else if (Lo) {
+ if (isInt16(v))
return CurDAG->getTargetNode(PPC::LI, MVT::i32, getI32Imm(v));
- } else {
- return CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(v >> 16));
- }
+
+ unsigned Hi = Hi16(v);
+ unsigned Lo = Lo16(v);
+
+ if (!Lo)
+ return CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(Hi));
+
+ SDOperand Top = CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(Hi));
+ return CurDAG->getTargetNode(PPC::ORI, MVT::i32, Top, getI32Imm(Lo));
}
case ISD::UNDEF:
if (N->getValueType(0) == MVT::i32)
OpenPOWER on IntegriCloud