[llvm] [LLVM][InstCombine] Enable constant folding for SVE asr,lsl and lsr intrinsics. (PR #137350)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 05:49:16 PDT 2025
================
@@ -1571,7 +1583,11 @@ simplifySVEIntrinsicBinOp(InstCombiner &IC, IntrinsicInst &II,
else
SimpleII = simplifyBinOp(Opc, Op1, Op2, DL);
- if (!SimpleII)
+ // An SVE intrinsic's result is always defined. However, this is not the case
+ // for its equivalent IR instruction (e.g. when shifting by an amount more
+ // than the data's bitwidth). Simplifications to an undefined result must be
+ // ignored to preserve the intrinsic's expected behaviour.
+ if (!SimpleII || isa<UndefValue>(SimpleII))
----------------
david-arm wrote:
There are multiple ways that `undef` (or `poison`?) can be returned, for example `Op1` itself could be undef. Do we have a test for this case? I assume you're taking the conservative approach here and just ignoring safe optimisations like `asr <vscale x 4 x i32> undef, <vscale x 4 x i32> splat(i32 0)` for now to reduce code complexity?
Also, is it always guaranteed to be `UndefValue` - do we ever return poison?
https://github.com/llvm/llvm-project/pull/137350
More information about the llvm-commits
mailing list