This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Add support for X*X self-multiplication
ClosedPublic

Authored by RKSimon on Jan 23 2022, 10:08 AM.

Details

Summary

D108992 added KnownBits handling for 'Quadratic Reciprocity' self-multiplication patterns (bit[1] == 0).

This patch adds selfmultiply handling to value tracking so demanded bits patterns can make use of it.

Diff Detail

Event Timeline

RKSimon created this revision.Jan 23 2022, 10:08 AM
RKSimon requested review of this revision.Jan 23 2022, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2022, 10:08 AM
lebedev.ri accepted this revision.Jan 23 2022, 10:24 AM

Seems fine to me.

This revision is now accepted and ready to land.Jan 23 2022, 10:24 AM

alive2 says the following is invalid:

define i5 @src(i5 %x) {
  %a = mul i5 %x, %x
  %b = and i5 %a, -3
  ret i5 %b
}

define i5 @tgt(i5 %x) {
  %a = mul i5 %x, %x
  ret i5 %a
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
i5 %x = undef

Source:
i5 %a = any
i5 %b = #x00 (0)	[based on undef value]

Target:
i5 %a = #x02 (2)
Source value: #x00 (0)
Target value: #x02 (2)
RKSimon planned changes to this revision.Jan 31 2022, 3:41 AM
RKSimon updated this revision to Diff 406268.Feb 6 2022, 11:21 AM

Updated with check for undef operand

This revision is now accepted and ready to land.Feb 6 2022, 11:21 AM
RKSimon requested review of this revision.Feb 6 2022, 11:21 AM
spatel accepted this revision.Feb 7 2022, 8:37 AM

LGTM

This revision is now accepted and ready to land.Feb 7 2022, 8:37 AM
This revision was landed with ongoing or failed builds.Feb 8 2022, 5:34 AM
This revision was automatically updated to reflect the committed changes.