This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Fixed issue with uitofp vector constant folding being treated as sitofp
ClosedPublic

Authored by RKSimon on Mar 23 2015, 11:55 AM.

Details

Summary

While the uitofp scalar constant folding treated an integer as an unsigned value (from lang ref):

%X = sitofp i8 -1 to double ; yields double:-1.0
%Y = uitofp i8 -1 to double ; yields double:255.0

The vector constant folding was always using sitofp:

%X = sitofp <2 x i8> <i8 -1, i8 -1> to <2 x double> ; yields <double -1.0, double -1.0>
%Y = uitofp <2 x i8> <i8 -1, i8 -1> to <2 x double> ; yields <double -1.0, double -1.0>

This patch fixes this so that the correct opcode is used for sitofp and uitofp.

%X = sitofp <2 x i8> <i8 -1, i8 -1> to <2 x double> ; yields <double -1.0, double -1.0>
%Y = uitofp <2 x i8> <i8 -1, i8 -1> to <2 x double> ; yields <double 255.0, double 255.0>

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 22498.Mar 23 2015, 11:55 AM
RKSimon retitled this revision from to [SelectionDAG] Fixed issue with uitofp vector constant folding being treated as sitofp.
RKSimon updated this object.
RKSimon edited the test plan for this revision. (Show Details)
RKSimon added reviewers: qcolombet, andreadb.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: Unknown Object (MLST).
hfinkel accepted this revision.Mar 23 2015, 12:12 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

LGTM.

This revision is now accepted and ready to land.Mar 23 2015, 12:12 PM
This revision was automatically updated to reflect the committed changes.