Page MenuHomePhabricator

[X86] Add SimplifyMultipleUseDemandedBitsForTargetNode X86ISD::ANDNP handling
Needs ReviewPublic

Authored by RKSimon on Jun 20 2022, 10:47 AM.

Details

Summary

See if we can remove X86ISD::ANDNP nodes by checking the state of the knownbits of the demanded elements.

This is equivalent to the generic ISD::AND handling, but flips the bits of the LHS operand to account for ANDNP.

Diff Detail

Unit TestsFailed

TimeTest
60,030 msx64 debian > libFuzzer.libFuzzer::value-profile-load.test
Script: -- : 'RUN: at line 2'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/lib/fuzzer -m64 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/fuzzer/LoadTest.cpp -fsanitize-coverage=trace-gep -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/fuzzer/X86_64DefaultLinuxConfig/Output/value-profile-load.test.tmp-LoadTest

Event Timeline

RKSimon created this revision.Jun 20 2022, 10:47 AM
Herald added a project: Restricted Project. · View Herald Transcript
RKSimon requested review of this revision.Jun 20 2022, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2022, 10:47 AM
pengfei added inline comments.Jun 20 2022, 6:05 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
41821

Why return LHS rather than ~LHS?

RKSimon planned changes to this revision.Jun 21 2022, 12:58 AM
RKSimon added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
41821

Doh! Nice catch! SimplifyMultipleUseDemandedBits isn't supposed to create nodes, I'll look at alternatives.

llvm/test/CodeGen/X86/combine-udiv.ll
700

It looks like we're missing and(mulh(x,c1),c2) -> mulh(x,and(c1,c2)) fold for cases where c2 is all/none bits.

RKSimon updated this revision to Diff 452159.Fri, Aug 12, 5:53 AM

Limit this to the RHS case which allows us to avoid ANDNP

craig.topper added inline comments.Fri, Aug 12, 9:32 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
42160

This comment was copy and pasted from ISD::AND and seems incorrect. It says "known 1" but we're checking Known.Zero. We're only doing it for the LHS so "one side" and "the other" should be more precise.