================
@@ -1977,6 +1989,37 @@ Value 
*AMDGPUCodeGenPrepareImpl::applyFractPat(IRBuilder<> &Builder,
   return insertValues(Builder, FractArg->getType(), ResultVals);
 }
 
+bool AMDGPUCodeGenPrepareImpl::visitCtpop(IntrinsicInst &I) {
+  uint32_t BitWidth, DestinationWidth, IntrinsicWidth;
+  if (!I.hasOneUse() || !I.getType()->isIntegerTy() ||
+      !ST.hasBCNT(BitWidth = I.getType()->getIntegerBitWidth()))
----------------
jmmartinez wrote:

Please do not try to put everything into a one-liner.

There is no need to assign variables at the same time you're trying to pass an 
argument to the function. 
It makes the code shorter, but harder to read.

Doing one single thing at a time makes everything much more readable.


```suggestion
  uint32_t DestinationWidth, IntrinsicWidth;
  
  if(!I.hasOneUse())
    return false;
    
  IntegerType *IType = dyn_cast<IntegerType>(I.getType());
  if(!IType)
    return false;
    
  uint32_t BitWidth = IType->getIntegerBitWidth();
  if (!ST.hasBCNT(BitWidth))
    return false;
```

In the if below, I was really not expecting the assignments on each side of the 
comparison either:
```cpp
  if ((DestinationWidth = MustBeSub->getType()->getIntegerBitWidth()) !=
      (IntrinsicWidth = TransformedIns->getType()->getIntegerBitWidth()))
```


https://github.com/llvm/llvm-project/pull/164847
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to