[PATCH] D155461: [InstCombine] Keep !unpredictable when combining select+add
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 08:49:47 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:540
Value *NewSel = Builder.CreateSelect(SI.getCondition(), Swapped ? C : OOp,
- Swapped ? OOp : C);
+ Swapped ? OOp : C, "", &SI);
if (isa<FPMathOperator>(&SI))
----------------
chfast wrote:
> goldstein.w.n wrote:
> > chfast wrote:
> > > I believe there are more case in the file where metadata copy is missed. I will try to identify them and create more tests cases. Can be in this review on later, depending on reviewers' suggestion.
> > Are there any other binops you want to preserve this flag for?
> I think it make sense for any binop because the condition of the select in this transformation remains unchanged (i.e. `!unpredictable` is still applicable).
I think you have this in the right place for most binops, but you should probably add additional tests for things like:
`sub`, `or`, `xor`, `and`, `mul`, `div`, `rem`, `llvm.min`, `llvm.max`, etc...
you probably don't need all but some variety of those (like 1/2 bitwise, div or rem, a few intrinsics) should provide better coverage.
================
Comment at: llvm/test/Transforms/InstCombine/unpredictable-select.ll:1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
----------------
nikic wrote:
> goldstein.w.n wrote:
> > chfast wrote:
> > > I created this test file. Is this good location?
> > Its fine.
> I would add this to the select_meta.ll test.
+1
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155461/new/
https://reviews.llvm.org/D155461
More information about the llvm-commits
mailing list