[llvm] [InstCombine] Implemented missed optimization in muldivrem (PR #140916)

Kshitij Paranjape via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 00:53:58 PDT 2025


kshitijvp wrote:

> Example:
> 
> ```
> ; Function Attrs: noinline nounwind uwtable
> define dso_local i64 @func1b(i64 noundef %0) {
>   %2 = alloca i64, align 8
>   store i64 %0, ptr %2, align 8
>   %3 = load i64, ptr %2, align 8
>   %4 = urem i64 %3, 84
>   %5 = udiv i64 %4, 7
>   ret i64 %5
> }
> ```
> 
> The optimization is not working properly on the above code. It is optimizing it to:
> 
> ```
> ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
> define dso_local i64 @func1b(i64 noundef %0) local_unnamed_addr #0 {
>   %2 = urem i64 %0, 84
>   %.lhs.trunc = trunc i64 %2 to i8
>   %3 = udiv i8 %.lhs.trunc, 7
>   %.zext = zext nneg i8 %3 to i64
>   ret i64 %.zext
> }
> ```

I don't understand why I am getting this error. Could someone help me out

https://github.com/llvm/llvm-project/pull/140916


More information about the llvm-commits mailing list