summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-03-17 17:03:52 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-03-17 17:03:52 +0000
commitad52f4f70c90b72efbcf270152397e6b2df47170 (patch)
treee69ff09a1d0c6136fe266838b5e819be62086207 /lib
parenteb7876083dcfb3a69264d14c130177ecf4fc4930 (diff)
downloadllvm-ad52f4f70c90b72efbcf270152397e6b2df47170.tar.gz
llvm-ad52f4f70c90b72efbcf270152397e6b2df47170.tar.bz2
llvm-ad52f4f70c90b72efbcf270152397e6b2df47170.tar.xz
R600/SI: Fix implementation of isInlineConstant() used by the verifier
The type of the immediates should not matter as long as the encoding is equivalent to the encoding of one of the legal inline constants. Tested-by: Michel Dänzer <michel.daenzer@amd.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/R600/SIInstrInfo.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/Target/R600/SIInstrInfo.cpp b/lib/Target/R600/SIInstrInfo.cpp
index f68dc2e0e4..3ed8dfa325 100644
--- a/lib/Target/R600/SIInstrInfo.cpp
+++ b/lib/Target/R600/SIInstrInfo.cpp
@@ -349,21 +349,32 @@ bool SIInstrInfo::isSALUInstr(const MachineInstr &MI) const {
}
bool SIInstrInfo::isInlineConstant(const MachineOperand &MO) const {
- if(MO.isImm()) {
- return MO.getImm() >= -16 && MO.getImm() <= 64;
- }
- if (MO.isFPImm()) {
- return MO.getFPImm()->isExactlyValue(0.0) ||
- MO.getFPImm()->isExactlyValue(0.5) ||
- MO.getFPImm()->isExactlyValue(-0.5) ||
- MO.getFPImm()->isExactlyValue(1.0) ||
- MO.getFPImm()->isExactlyValue(-1.0) ||
- MO.getFPImm()->isExactlyValue(2.0) ||
- MO.getFPImm()->isExactlyValue(-2.0) ||
- MO.getFPImm()->isExactlyValue(4.0) ||
- MO.getFPImm()->isExactlyValue(-4.0);
+
+ union {
+ int32_t I;
+ float F;
+ } Imm;
+
+ if (MO.isImm()) {
+ Imm.I = MO.getImm();
+ } else if (MO.isFPImm()) {
+ Imm.F = MO.getFPImm()->getValueAPF().convertToFloat();
+ } else {
+ return false;
}
- return false;
+
+ // The actual type of the operand does not seem to matter as long
+ // as the bits match one of the inline immediate values. For example:
+ //
+ // -nan has the hexadecimal encoding of 0xfffffffe which is -2 in decimal,
+ // so it is a legal inline immediate.
+ //
+ // 1065353216 has the hexadecimal encoding 0x3f800000 which is 1.0f in
+ // floating-point, so it is a legal inline immediate.
+ return (Imm.I >= -16 && Imm.I <= 64) ||
+ Imm.F == 0.0f || Imm.F == 0.5f || Imm.F == -0.5f || Imm.F == 1.0f ||
+ Imm.F == -1.0f || Imm.F == 2.0f || Imm.F == -2.0f || Imm.F == 4.0f ||
+ Imm.F == -4.0f;
}
bool SIInstrInfo::isLiteralConstant(const MachineOperand &MO) const {