X86: Fix GenCAS DCHECK(kUseBakerReadBarrier) misplacement

This commit fixes a bug previously introduced by refactoring VarHandle
compareAndSet and UnsafeCAS. The check for using only baker read barrier
was supposed to be done only for references.

Test: ART_READ_BARRIER_TYPE=TABLE_LOOKUP art/test.py --host --all-compiler --optimizing --32 -r
Bug: 168645609
Change-Id: Ic6d1cf5ca0e3c4d10abb0d7a793623592a11c74c
diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc
index d642388..73c1009 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -2118,11 +2118,11 @@
   Location out = locations->Out();
   DCHECK_EQ(out.AsRegister<Register>(), EAX);
 
-  // The only read barrier implementation supporting the
-  // UnsafeCASObject intrinsic is the Baker-style read barriers.
-  DCHECK(!kEmitCompilerReadBarrier || kUseBakerReadBarrier);
-
   if (type == DataType::Type::kReference) {
+    // The only read barrier implementation supporting the
+    // UnsafeCASObject intrinsic is the Baker-style read barriers.
+    DCHECK(!kEmitCompilerReadBarrier || kUseBakerReadBarrier);
+
     Register temp = locations->GetTemp(0).AsRegister<Register>();
     Register temp2 = locations->GetTemp(1).AsRegister<Register>();
     GenReferenceCAS(invoke, codegen, expected_value, new_value, base, offset, temp, temp2);