[llvm] 707bb42 - [InstCombine] Require immediate constant in canEvaluateShifted()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 07:12:57 PST 2023


Author: Nikita Popov
Date: 2023-11-10T16:12:49+01:00
New Revision: 707bb421637140f0e58cebc48c6204246e68e81d

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

LOG: [InstCombine] Require immediate constant in canEvaluateShifted()

Otherwise we risk infinite loops when shift constant expressions
are no longer supported.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index aa249f63d9e5c44..1aac93731474291 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -560,8 +560,8 @@ static bool canEvaluateShiftedShift(unsigned OuterShAmt, bool IsOuterShl,
 /// this succeeds, getShiftedValue() will be called to produce the value.
 static bool canEvaluateShifted(Value *V, unsigned NumBits, bool IsLeftShift,
                                InstCombinerImpl &IC, Instruction *CxtI) {
-  // We can always evaluate constants shifted.
-  if (isa<Constant>(V))
+  // We can always evaluate immediate constants.
+  if (match(V, m_ImmConstant()))
     return true;
 
   Instruction *I = dyn_cast<Instruction>(V);


        


More information about the llvm-commits mailing list