This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Remove DIVUW/REMUW patterns that don't seem right
AbandonedPublic

Authored by craig.topper on Nov 26 2020, 9:31 PM.

Details

Summary

These patterns are looking for DIVUW/REMUW with inputs zero extended from 32 bits to 64 and the result being zero extended from 32 bits to 64 bits. This is selected to a DIVUW/REMUW instruction.

As far as I can tell DIVUW/REMUW will sign extend bit 31 in the result. So this isel pattern would only work if the pattern guaranteed that bit 31 of the result was zero so that sign extend would produce zeros. I don't believe the input being zero extended from 32 to 64 bits guarantee that. For example won't (divuw 0xffffffff, 1) produce 0xffffffffffffffff? Similarly won't (remuw 0x80000000, 0xffffffff) produce 0xffffffff80000000?

Diff Detail

Event Timeline

craig.topper created this revision.Nov 26 2020, 9:31 PM
craig.topper requested review of this revision.Nov 26 2020, 9:31 PM
craig.topper abandoned this revision.Nov 26 2020, 9:38 PM

I misread that this was producing DIVU/REMU. Nevermind.

Though it probably isn't safe that we're matching (and X, 0xffffffff) on the input due to zexti32 handling both assertzext and and X, 0xffffffff. Removing an and seems wrong.