This is an archive of the discontinued LLVM Phabricator instance.

[X86] Prevent several calls to ISD::isConstantSplatVector from returning a narrower APInt than the original scalar type
ClosedPublic

Authored by craig.topper on Aug 21 2017, 10:10 PM.

Details

Summary

ISD::isConstantSplatVector can shrink to the smallest splat width. But we don't check the size of the resulting APInt at all. This can cause us to misinterpret the results.

This patch just adds a flag to prevent the APInt from changing width.

Fixes PR34271.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Aug 21 2017, 10:10 PM
chandlerc accepted this revision.Aug 21 2017, 10:19 PM

LGTM, minor nits below, feel free to submit whenever.

include/llvm/CodeGen/SelectionDAGNodes.h
88 ↗(On Diff #112112)

'returns' -> 'sets SplatValue to'

test/CodeGen/X86/pr34271.ll
7 ↗(On Diff #112112)

The previous version of the generated code had a plausible instruction sequence that ultimately did the wrong thing... Is it possible to actually check the values being added here?

This revision is now accepted and ready to land.Aug 21 2017, 10:19 PM
This revision was automatically updated to reflect the committed changes.