[llvm] [InstCombine] Propagate exact flags in shift-combine transforms (PR #88340)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 18:00:36 PDT 2024
================
@@ -1398,8 +1398,12 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
if (match(Op0, m_LShr(m_Value(X), m_APInt(C1)))) {
// Oversized shifts are simplified to zero in InstSimplify.
unsigned AmtSum = ShAmtC + C1->getZExtValue();
- if (AmtSum < BitWidth)
- return BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum));
+ if (AmtSum < BitWidth) {
+ auto *NewLShr =
+ BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum));
+ NewLShr->setIsExact(I.isExact() && cast<Instruction>(Op0)->isExact());
+ return NewLShr;
+ }
----------------
nikic wrote:
I think a test for this case is missing? You have tests for the variant with the interleaved trunc, but not a plain double lshr?
https://github.com/llvm/llvm-project/pull/88340
More information about the llvm-commits
mailing list