[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 09:12:54 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/test/CodeGen/X86/known-never-zero.ll:56
+ %z = select i1 %c, i32 %y, i32 122
+ %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
+ ret i32 %r
----------------
RKSimon wrote:
> Any idea why we sometimes get branches and sometimes CMOV? IIRC CodeGenPrepare does attempt to determine if a CTTZ/CTLZ is non-zero?
I'm not sure. The transform happens in: `visitCTTZ`. See my comment on `fshr`, but I think there is some inter-dependency with the middle end that might be subtly affecting things.
================
Comment at: llvm/test/CodeGen/X86/known-never-zero.ll:67
+; CHECK-NEXT: cmovnel %esi, %eax
+; CHECK-NEXT: testl %eax, %eax
+; CHECK-NEXT: je .LBB3_1
----------------
As an aside, this is a todo:
`Cmp(Cmov(CC, Zero, Non-Zero), Zero)` should be `(Cmp(CC))`
================
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:
> 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?
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