This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Add an isExtendedTrueVal helper.
AcceptedPublic

Authored by paquette on Nov 18 2020, 4:29 PM.

Details

Reviewers
aemerson
arsenm
Summary

Add a helper equivalent to TargetLowering::isExtendedTrueVal and test it.

This is necessary to implement one of the simplifications in TargetLowering::SimplifySetCC.

Diff Detail

Event Timeline

paquette created this revision.Nov 18 2020, 4:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2020, 4:29 PM
paquette requested review of this revision.Nov 18 2020, 4:29 PM
aemerson added inline comments.Nov 18 2020, 11:17 PM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
983

Not saying this is wrong, but what's the rationale here for Val needing to be exactly 1 for s1? If The type is s1 then isn't either -1 or 1 equivalently true?

paquette added inline comments.Nov 19 2020, 2:13 PM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
983

I think that's very philosophical, but I guess I'm fine either way?

I could believe that there's no meaningful distinction between 1 and -1 in 1-bit world.

aemerson added inline comments.Nov 20 2020, 12:05 PM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
983

I guess it depends on what the contract is for this function when the type size is < 64 bits. I know that if you get the constant value from a G_CONSTANT i1 true then it ends up as a -1 int64_t, so passing to this function would return false. Maybe we should mask off the upper bits on entry?

arsenm requested changes to this revision.Mar 30 2021, 3:59 PM
arsenm added inline comments.
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
379–380

Should pass LLT by value

llvm/lib/CodeGen/GlobalISel/Utils.cpp
983

i1 true constants are treated as -1 everywhere else

This revision now requires changes to proceed.Mar 30 2021, 3:59 PM
paquette updated this revision to Diff 335898.Apr 7 2021, 12:13 PM

The original code was confusing. Rewrote this to use getICmpTrueVal + APInt. I think this simplifies the behaviour for s1 quite a bit.

arsenm accepted this revision.Sep 21 2022, 5:27 PM

LGTM

This revision is now accepted and ready to land.Sep 21 2022, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 5:27 PM