[llvm] [InstCombine] Use the select condition to try to constant fold binops into select (PR #84696)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 09:37:16 PDT 2024


goldsteinn wrote:

> > ```
> > define i32 @before(i1 %cond) {
> >   %sel = select i1 %cond, i32 32, i32 0
> >   call void @use(i32 %sel)
> >   %ret = or disjoint i32 %sel, 16
> >   ret i32 %ret
> > }
> > 
> > define i32 @after(i1 %cond) {
> >   %sel = select i1 %cond, i32 32, i32 0
> >   call void @use(i32 %sel)
> >   %ret = select i1 %cond, i32 48, i32 16
> >   ret i32 %ret
> > }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > I don't think the latter form is better than the former. Do we need the one-use check?
> 
> I still don't like these things happen :( It is okay for div/rem. But I am not sure it is always a win for mul. We need to discuss this problem with other backend maintainers.

I'm happy to drop this for `mul` and only keep for `div`/`rem`.

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


More information about the llvm-commits mailing list