[PATCH] D149299: [X86] Add tests for checking `isKnownNeverZero`; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 10:45:49 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/test/CodeGen/X86/known-never-zero.ll:288
+  %shl = shl i32 %x, %sub
+  %z = or i32 %shl, %shr
+  %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
----------------
RKSimon wrote:
> goldstein.w.n wrote:
> > RKSimon wrote:
> > > use the fshl/fshr intrinsics here to help ensure you're testing the ROTL/ROTR paths
> > I originally did this, but as I was working on the change I noticed we are also missing non-zero case for funnel-shift in the middle end. I filled in the middle-end case and found it was affecting the `CodeGen` test and figured it be best to avoid that kind of inter-dependency. Changes to `ValueTracking.cpp` shouldn't mess with a test in `CodeGen/X86`.
> > 
> > Maybe different `llc` flags?
> CodeGenPrepare (despeculateCountZeros) is trying to prevent CTLZ/CTTZ zero-input branching from appearing, using ValueTracking's variant of isKnownNonZero
> 
> I wonder if there's something other than CTTZ we could use?
I see. We don't use it in many places. Let me post a patch to try and evaluate `SetCC` based on known bits, then we can use that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149299



More information about the llvm-commits mailing list