AMDGPU: Check cheaper condition before SignBitIsZero
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 24 Feb 2016 04:55:29 +0000 (04:55 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 24 Feb 2016 04:55:29 +0000 (04:55 +0000)
Don't do an expensive computeKnownBits call when we
can do the cheap check for legal offsets first.

llvm-svn: 261720

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

index 33af12e..21716be 100644 (file)
@@ -1063,14 +1063,13 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFScratch(SDValue Addr, SDValue &Rsrc,
   if (CurDAG->isBaseWithConstantOffset(Addr)) {
     SDValue N0 = Addr.getOperand(0);
     SDValue N1 = Addr.getOperand(1);
+
     // Offsets in vaddr must be positive.
-    if (CurDAG->SignBitIsZero(N0)) {
-      ConstantSDNode *C1 = cast<ConstantSDNode>(N1);
-      if (isLegalMUBUFImmOffset(C1)) {
-        VAddr = N0;
-        ImmOffset = CurDAG->getTargetConstant(C1->getZExtValue(), DL, MVT::i16);
-        return true;
-      }
+    ConstantSDNode *C1 = cast<ConstantSDNode>(N1);
+    if (isLegalMUBUFImmOffset(C1) && CurDAG->SignBitIsZero(N0)) {
+      VAddr = N0;
+      ImmOffset = CurDAG->getTargetConstant(C1->getZExtValue(), DL, MVT::i16);
+      return true;
     }
   }