[llvm] ffe58de - [X86] [AMX] Fix the test case failure caused by D107544.

Bing1 Yu via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 18 07:31:11 PDT 2021


Author: Bing1 Yu
Date: 2021-08-18T22:27:22+08:00
New Revision: ffe58de39319b42b46319473263b59bd68ceee67

URL: https://github.com/llvm/llvm-project/commit/ffe58de39319b42b46319473263b59bd68ceee67
DIFF: https://github.com/llvm/llvm-project/commit/ffe58de39319b42b46319473263b59bd68ceee67.diff

LOG: [X86] [AMX] Fix the test case failure caused by D107544.

The issue can be duplicated when EXPENSIVE_CHECKS is specified for llvm
build. Thank Simon report this issue at
https://bugs.llvm.org/show_bug.cgi?id=51513. We need return correct
value for the changed IR.

Reviewed By: RKSimon, LuoYuanke

Differential Revision: https://reviews.llvm.org/D108269

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86LowerAMXType.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86LowerAMXType.cpp b/llvm/lib/Target/X86/X86LowerAMXType.cpp
index a2bcc98f3d5b..e150f2dbc354 100644
--- a/llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -898,10 +898,12 @@ bool X86LowerAMXCast::combineAMXcast(TargetLibraryInfo *TLI) {
   Convert(Vec2TileInsts, Intrinsic::x86_cast_tile_to_vector);
   Convert(Tile2VecInsts, Intrinsic::x86_cast_vector_to_tile);
 
-  auto EraseInst = [](SmallVectorImpl<Instruction *> &Insts) {
+  auto EraseInst = [&](SmallVectorImpl<Instruction *> &Insts) {
     for (auto *Inst : Insts) {
-      if (Inst->use_empty())
+      if (Inst->use_empty()) {
         Inst->eraseFromParent();
+        Change = true;
+      }
     }
   };
 
@@ -912,7 +914,7 @@ bool X86LowerAMXCast::combineAMXcast(TargetLibraryInfo *TLI) {
   for (BasicBlock &BB : Func) {
     for (Instruction &I : BB) {
       if (isAMXCast(&I)) {
-        if (PHINode *PN = dyn_cast<PHINode>(I.getOperand(0)))
+        if (isa<PHINode>(I.getOperand(0)))
           PhiCastWorkList.push_back(&I);
       }
     }
@@ -1036,17 +1038,18 @@ class X86LowerAMXTypeLegacyPass : public FunctionPass {
   }
 
   bool runOnFunction(Function &F) override {
+    bool C = false;
     TargetMachine *TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
     TargetLibraryInfo *TLI =
         &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
     X86LowerAMXCast LAC(F);
-    LAC.combineAMXcast(TLI);
+    C |= LAC.combineAMXcast(TLI);
     // There might be remaining AMXcast after combineAMXcast and they should be
     // handled elegantly.
-    LAC.transformAllAMXCast();
+    C |= LAC.transformAllAMXCast();
 
     X86LowerAMXType LAT(F);
-    bool C = LAT.visit();
+    C |= LAT.visit();
 
     // Prepare for fast register allocation at O0.
     // Todo: May better check the volatile model of AMX code, not just


        


More information about the llvm-commits mailing list