[PATCH] D71558: [llvm][MIRVRegNamerUtils] Adding hashing on CImm / FPImm MachineOperands.
Puyan Lotfi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 15:28:18 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf63b64c0c3b4: [llvm][MIRVRegNamerUtils] Adding hashing on CImm / FPImm MachineOperands. (authored by plotfi).
Changed prior to commit:
https://reviews.llvm.org/D71558?vs=234101&id=234175#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71558/new/
https://reviews.llvm.org/D71558
Files:
llvm/lib/CodeGen/MIRVRegNamerUtils.cpp
llvm/test/CodeGen/MIR/Generic/CFPImmMIRCanonHash.mir
Index: llvm/test/CodeGen/MIR/Generic/CFPImmMIRCanonHash.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/MIR/Generic/CFPImmMIRCanonHash.mir
@@ -0,0 +1,14 @@
+# RUN: llc -run-pass mir-canonicalizer -o - %s | FileCheck %s
+---
+name: cimm_fpimm_hash_test
+body: |
+ bb.0:
+ ; CHECK: _1:_(s1) = G_CONSTANT i1 true
+ ; CHECK: _1:_(s1) = G_CONSTANT i1 false
+ ; CHECK: _1:_(s32) = G_FCONSTANT float
+ ; CHECK: _1:_(s32) = G_FCONSTANT float
+ %0:_(s1) = G_CONSTANT i1 true
+ %1:_(s1) = G_CONSTANT i1 false
+ %2:_(s32) = G_FCONSTANT float 1.0
+ %3:_(s32) = G_FCONSTANT float 0.0
+...
Index: llvm/lib/CodeGen/MIRVRegNamerUtils.cpp
===================================================================
--- llvm/lib/CodeGen/MIRVRegNamerUtils.cpp
+++ llvm/lib/CodeGen/MIRVRegNamerUtils.cpp
@@ -53,6 +53,13 @@
// Gets a hashable artifact from a given MachineOperand (ie an unsigned).
auto GetHashableMO = [this](const MachineOperand &MO) -> unsigned {
switch (MO.getType()) {
+ case MachineOperand::MO_CImmediate:
+ return hash_combine(MO.getType(), MO.getTargetFlags(),
+ MO.getCImm()->getZExtValue());
+ case MachineOperand::MO_FPImmediate:
+ return hash_combine(
+ MO.getType(), MO.getTargetFlags(),
+ MO.getFPImm()->getValueAPF().bitcastToAPInt().getZExtValue());
case MachineOperand::MO_Immediate:
return MO.getImm();
case MachineOperand::MO_TargetIndex:
@@ -70,8 +77,6 @@
// TODO: Handle the following Immediate/Index/ID/Predicate cases. They can
// be hashed on in a stable manner.
- case MachineOperand::MO_CImmediate:
- case MachineOperand::MO_FPImmediate:
case MachineOperand::MO_FrameIndex:
case MachineOperand::MO_ConstantPoolIndex:
case MachineOperand::MO_JumpTableIndex:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71558.234175.patch
Type: text/x-patch
Size: 1875 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/9e3e789d/attachment.bin>
More information about the llvm-commits
mailing list