This is an archive of the discontinued LLVM Phabricator instance.

[X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS
ClosedPublic

Authored by ManuelJBrito on Feb 27 2023, 11:41 AM.

Details

Summary

Ignoring freeze(undef) if it has multiple uses in LowerAVXCONCAT_VECTORS causes the custom INSERT_SUBVECTOR for vector widening to be ignored.

For example in https://godbolt.org/z/7hacPe1KM extra vinsertf128 instructions are introduced.

This is necessary to lower mm512_cast*128 intel intrinsics as no-op intrinsics.

Diff Detail

Event Timeline

ManuelJBrito created this revision.Feb 27 2023, 11:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 11:41 AM
ManuelJBrito requested review of this revision.Feb 27 2023, 11:41 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 27 2023, 11:41 AM
RKSimon added inline comments.Feb 28 2023, 3:33 AM
clang/test/CodeGen/X86/avx-cast-builtins.c
1

Why did you lose this?

Recover mistakenly drop flag in avx-cast-builtins.
I was experimenting and forgot i had removed it.

RKSimon accepted this revision.Feb 28 2023, 5:50 AM

LGTM

This revision is now accepted and ready to land.Feb 28 2023, 5:50 AM

@ManuelJBrito Any luck with getting this committed? Your first attempt was reverted but was it just because of the bad Differential Revision tag?

I originally reverted it because of the wrong tag, but there were also some buildbot failures (see https://lab.llvm.org/buildbot/#/builders/139/builds/36736).
It appears to be failing an assert in DiagnosticsEngine::DiagStateMap::append, but i'm not very familiar with this part so i will have to investigate further.

It seems the build failure was caused by a known crash https://github.com/llvm/llvm-project/issues/55263. I tried to find some workaround but unsuccessfully.

So I'm thinking I can drop the end-to-end tests for now and commit them when the crash is fixed and for now just rely on the separate frontend and backend tests for regressions.

Is this OK with you @RKSimon ?

It seems the build failure was caused by a known crash https://github.com/llvm/llvm-project/issues/55263. I tried to find some workaround but unsuccessfully.

@pengfei Do you know what's going on with this bug?

So I'm thinking I can drop the end-to-end tests for now and commit them when the crash is fixed and for now just rely on the separate frontend and backend tests for regressions.

Is this OK with you @RKSimon ?

Let's see if we can unstick PR55263 first - yak shaving :(

aqjune added a subscriber: aqjune.Mar 8 2023, 2:47 PM
aqjune added inline comments.
clang/test/CodeGen/X86/avx-cast-builtins.c
1

This line contains %s twice, which seems to cause the crash.

Would removing one of %s resolve the crash issue? On my machine removing one of those worked well; with two %s; it crashed.

1

Actually, with FileCheck's argument counted there are three %s, but it isn't important; I meant two %s in clang_cc1's arguments.

ManuelJBrito added inline comments.Mar 9 2023, 2:53 AM
clang/test/CodeGen/X86/avx-cast-builtins.c
1

Oops .. I should have noticed that...
I will try to commit again with this fix . Thanks for looking at this aqjune!!

This revision was landed with ongoing or failed builds.Mar 9 2023, 3:02 AM
This revision was automatically updated to reflect the committed changes.

I think the point of the hasOneUse check is to avoid a possible miscompile; if a FREEZE has more than one use, all users need to see the same value. So not sure dropping the check is correct in general.

I think the point of the hasOneUse check is to avoid a possible miscompile; if a FREEZE has more than one use, all users need to see the same value. So not sure dropping the check is correct in general.

Good point.
This patch is not correct, must be reverted.
The shufflevectors create copies of a same 'freeze poison'. These copies must see the same value, and that's not the case after this patch.

Reverted. I'll reassess what can be done here.