[llvm] r212794 - [X86] AVX512: Simplify logic in isCDisp8

Adam Nemet anemet at apple.com
Thu Jul 10 22:23:13 PDT 2014


Author: anemet
Date: Fri Jul 11 00:23:12 2014
New Revision: 212794

URL: http://llvm.org/viewvc/llvm-project?rev=212794&view=rev
Log:
[X86] AVX512: Simplify logic in isCDisp8

It was computing the VL/n case as:
  MemObjSize = VectorByteSize / ElemByteSize / Divider * ElemByteSize

ElemByteSize not only falls out but VectorByteSize/Divider now actually
matches the definition of VL/n.

Also some formatting fixes.

Modified:
    llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp?rev=212794&r1=212793&r2=212794&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp Fri Jul 11 00:23:12 2014
@@ -185,7 +185,8 @@ static bool isDisp8(int Value) {
 /// isCDisp8 - Return true if this signed displacement fits in a 8-bit
 /// compressed dispacement field.
 static bool isCDisp8(uint64_t TSFlags, int Value, int& CValue) {
-  assert((TSFlags & X86II::EncodingMask) >> X86II::EncodingShift == X86II::EVEX &&
+  assert(((TSFlags & X86II::EncodingMask) >>
+          X86II::EncodingShift == X86II::EVEX) &&
          "Compressed 8-bit displacement is only valid for EVEX inst.");
 
   unsigned CD8E = (TSFlags >> X86II::EVEX_CD8EShift) & X86II::EVEX_CD8EMask;
@@ -195,7 +196,7 @@ static bool isCDisp8(uint64_t TSFlags, i
     CValue = Value;
     return isDisp8(Value);
   }
-  
+
   unsigned MemObjSize = 1U << CD8E;
   if (CD8V & 4) {
     // Fixed vector length
@@ -208,10 +209,9 @@ static bool isCDisp8(uint64_t TSFlags, i
       EVEX_LL += ((TSFlags >> X86II::VEXShift) & X86II::EVEX_L2) ? 2 : 0;
       assert(EVEX_LL < 3 && "");
 
-      unsigned NumElems = (1U << (EVEX_LL + 4)) / MemObjSize;
-      NumElems /= 1U << (CD8V & 0x3);
-
-      MemObjSize *= NumElems;
+      unsigned VectorByteSize = 1U << (EVEX_LL + 4);
+      unsigned Divider = 1U << (CD8V & 0x3);
+      MemObjSize = VectorByteSize / Divider;
     }
   }
 





More information about the llvm-commits mailing list