[PATCH] D131260: [DAG] select Cond, -1, C --> or (sext Cond), C if Cond is MVT::i1

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 07:43:21 PDT 2022


shchenz added inline comments.


================
Comment at: llvm/test/CodeGen/PowerPC/signbit-shift.ll:142
+; CHECK-NEXT:    li 3, 42
+; CHECK-NEXT:    isellt 3, 3, 4
 ; CHECK-NEXT:    blr
----------------
deadalnix wrote:
> deadalnix wrote:
> > shchenz wrote:
> > > The changes in this file seem regressions, especially for this case, more instructions and more registers. Do we know why?
> > Yes. The PowerPC backend request for select_cc instruction. The select_cc instruction is not turned into arythmetic the way regular select instructions are.
> > 
> > This patch changes how select -> arithmetic transformations are done, which enable more transform in general, but specifically on PowerPC, this cases problems because it causes either select_cc to not be generated due select -> arithmetic transformations, or, alternatively, if the promotion to select_cc is prioritized, then the cases where the arithmetic transform was beneficial are not done.
> > 
> > Do we have a good idea when select_cc -> arithmetic is beneficial? If we have something reasonable here, we can add the select_cc transforms and get these regression dealt with.
> If you want to see the difference when one takes priority over the other: https://reviews.llvm.org/D131260?vs=458558&id=458561
Hmm, PowerPC sets `SELECT_CC` as custom for type i32/i64, but it does not mean the customization is  better than the arithmetic way here. In fact it is worse as shown in the case. If on other targets, the customization for `SELECT_CC` is better,  then we may need to adjust the current target hook `foldSelectOfConstants()`(for example, if we know the SELECT can be optimized to `SELECT_CC` on some target and `SELECT_CC` is better, we return false?) or we may need to re-implement the SELECT combining logic here on PowerPC for SELECT_CC. IMO, the first one makes more sense. Thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131260/new/

https://reviews.llvm.org/D131260



More information about the llvm-commits mailing list