[llvm] 79e668f - [InstCombine] Fix funnel shift bailout in demanded bits simplification

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 05:39:16 PDT 2024


Author: Nikita Popov
Date: 2024-06-18T14:39:06+02:00
New Revision: 79e668f9700cc8321e7ee0eecd3b82c108aea6de

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

LOG: [InstCombine] Fix funnel shift bailout in demanded bits simplification

We shouldn't simply return here -- we still need to compute the
known bits and fall through to generic handling.

This fixes a -instcombine-verify-known-bits violation in funnel.ll.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 1b00ceec3bcce..35425c5d0882e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -638,8 +638,10 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
           if (auto Opt = convertOrOfShiftsToFunnelShift(*Inst)) {
             auto [IID, FShiftArgs] = *Opt;
             if ((IID == Intrinsic::fshl || IID == Intrinsic::fshr) &&
-                FShiftArgs[0] == FShiftArgs[1])
-              return nullptr;
+                FShiftArgs[0] == FShiftArgs[1]) {
+              computeKnownBits(I, Known, Depth, CxtI);
+              break;
+            }
           }
         }
       }
@@ -718,8 +720,10 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
           if (auto Opt = convertOrOfShiftsToFunnelShift(*Inst)) {
             auto [IID, FShiftArgs] = *Opt;
             if ((IID == Intrinsic::fshl || IID == Intrinsic::fshr) &&
-                FShiftArgs[0] == FShiftArgs[1])
-              return nullptr;
+                FShiftArgs[0] == FShiftArgs[1]) {
+              computeKnownBits(I, Known, Depth, CxtI);
+              break;
+            }
           }
         }
       }


        


More information about the llvm-commits mailing list