diff options
author | David Goodwin <david_goodwin@apple.com> | 2009-07-14 00:57:56 +0000 |
---|---|---|
committer | David Goodwin <david_goodwin@apple.com> | 2009-07-14 00:57:56 +0000 |
commit | f354d36027f21554f43b365cd07cf965a7687096 (patch) | |
tree | 2f3e9b83a10b99dca3a332a9ff4f0c5d62cc772a /lib | |
parent | bd760a50153e3f543e5ccf0d5d6a34e3a33bd88e (diff) | |
download | external_llvm-f354d36027f21554f43b365cd07cf965a7687096.zip external_llvm-f354d36027f21554f43b365cd07cf965a7687096.tar.gz external_llvm-f354d36027f21554f43b365cd07cf965a7687096.tar.bz2 |
Fix detection of valid BFC immediates.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/ARM/ARMInstrInfo.td | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index b3a52d6..17e7365 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -168,16 +168,16 @@ def bf_inv_mask_imm : Operand<i32>, uint32_t v = (uint32_t)N->getZExtValue(); if (v == 0xffffffff) return 0; - // naive checker. should do better, but simple is best for now since it's - // more likely to be correct. - while (v & 1) v >>= 1; // shift off the leading 1's - if (v) - { - while (!(v & 1)) v >>=1; // shift off the mask - while (v & 1) v >>= 1; // shift off the trailing 1's - } - // if this is a mask for clearing a bitfield, what's left should be zero. - return (v == 0); + // there can be 1's on either or both "outsides", all the "inside" + // bits must be 0's + unsigned int lsb = 0, msb = 31; + while (v & (1 << msb)) --msb; + while (v & (1 << lsb)) ++lsb; + for (unsigned int i = lsb; i <= msb; ++i) { + if (v & (1 << i)) + return 0; + } + return 1; }] > { let PrintMethod = "printBitfieldInvMaskImmOperand"; } |