[PATCH] D145220: [X86][InstCombine] Simplify some `pternlog` intrinsics

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 3 13:40:57 PST 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp:588
+  bool BCIsConst = isa<Constant>(B) && isa<Constant>(C);
+  bool ABCIsConst = isa<Constant>(A) && isa<Constant>(B) && isa<Constant>(C);
+
----------------
goldstein.w.n wrote:
> craig.topper wrote:
> > craig.topper wrote:
> > > If everything is const can we someone use the immediate as a lookup table instead of manually describing every case?
> > somehow* not someone
> > If everything is const can we someone use the immediate as a lookup table instead of manually describing every case?
> 
> Yes although there are some IMM where we only need AC/AB/BC so think we would still want to check the IMM.
> 
> Are you concerned about compile time overhead? If not keeping the same logic for const / non-const seems simpler and less error prone.
> > If everything is const can we someone use the immediate as a lookup table instead of manually describing every case?
> 
> Yes although there are some IMM where we only need AC/AB/BC so think we would still want to check the IMM.
> 
> Are you concerned about compile time overhead? If not keeping the same logic for const / non-const seems simpler and less error prone.

If all three are const we can just implement it with a loop above all the bits. Its just:
```
for(i : bitwidth()) {
res[i] = (imm >> ((A[i] << 2) + (B[i] << 1) + (C[i] << 0))) & 1
}
```
but still issue of we will miss cases where `C` is non-constant but also truly unneeded.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145220



More information about the llvm-commits mailing list