[PATCH] D104049: [AMDGPU] [CodeGen] Fold negate llvm.amdgcn.class into test mask

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 15 17:41:38 PDT 2021


arsenm added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:827
+    return false;
+  else {
+    auto *LHS = I.getOperand(0);
----------------
No else after return


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:831-832
+
+    if (isa<IntrinsicInst>(LHS) && isa<ConstantInt>(RHS) &&
+        cast<ConstantInt>(RHS)->getSExtValue() == -1)
+      IntrinsicCall = dyn_cast<IntrinsicInst>(LHS);
----------------
arsenm wrote:
> Using dyn_cast and isa is redundant, just use dyn_cast and check the result
Using m_Not would still be clearer


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:831-833
+    if (isa<IntrinsicInst>(LHS) && isa<ConstantInt>(RHS) &&
+        cast<ConstantInt>(RHS)->getSExtValue() == -1)
+      IntrinsicCall = dyn_cast<IntrinsicInst>(LHS);
----------------
Using dyn_cast and isa is redundant, just use dyn_cast and check the result


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:851
+      1, ConstantInt::get(Arg->getType(),
+                          ~Arg->getZExtValue() & ((1ull << 32) - 1)));
+  I.replaceAllUsesWith(IntrinsicCall);
----------------
There are fewer bits in the test mask than this


================
Comment at: llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-foldnegate.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -amdgpu-codegenprepare -verify -S %s -o - | FileCheck %s
----------------
You didn't actually generate these checks. The operand tests are mostly missing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104049/new/

https://reviews.llvm.org/D104049



More information about the llvm-commits mailing list