[llvm] [DAGCombine] Remove oneuse restrictions for RISCV in folding (shl (add_nsw x, c1)), c2) and folding (shl(sext(add x, c1)), c2) in some scenarios (PR #101294)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 22:50:01 PST 2024


lukel97 wrote:

> Regression:
> 
> ```
> 
> ; bin/llc -mtriple=riscv64 -mattr=+zba test.ll -o -
> 
> define i64 @test(i64 %x) {
> 
> entry:
> 
>   %or = or i64 %x, 1
> 
>   %mul = mul nuw nsw i64 %or, 3
> 
>   ret i64 %mul
> 
> }
> 
> ```
> 
> Before: https://godbolt.org/z/6vKhhxrWr
> 
> ```
> 
> test:
> 
>         ori     a0, a0, 1
> 
>         sh1add  a0, a0, a0
> 
>         ret
> 
> ```
> 
> After:
> 
> ```
> 
> test:
> 
>         ori     a1, a0, 1
> 
>         slli    a0, a0, 1
> 
>         ori     a0, a0, 2
> 
>         add     a0, a0, a1
> 
>         ret
> 
> ```


Has there been a fix for this yet? If not it would be good to create an issue so we don't forget about it. 

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


More information about the llvm-commits mailing list