Page MenuHomePhabricator

[AMDGPU][MC] Corrected handling of "-" before expressions
ClosedPublic

Authored by dp on Apr 12 2019, 10:09 AM.

Details

Summary

See bug 41156: https://bugs.llvm.org/show_bug.cgi?id=41156

This is the first part of a fix. This change corrects the following bug: when a constant expression starts with a "-" followed by a number, the negation operation is applied to the whole expression rather than to the first number.

For example, the sequence

s_sub_u32 s0, s0, -2+1

results in the same code as the following:

s_sub_u32 s0, s0, -3

This change also disables expressions which start with floating-point literals (with an optional sign).
Examples of enabled operands:

1.0
-1.0

Examples of disabled operands:

-1.0 + x

Without this change we cannot correctly handle negative floating-point literals like -1.0 because
llvm does not support fp operations: operands of expressions are handled as integers.
Note that:

  • we cannot use llvm expressions parser for handling fp literals because unary "-" would be handled as an integer negation.
  • we cannot handle unary "-" ourselves as it may start an expression (e.g. "-1.0 + x").

Diff Detail

Repository
rL LLVM

Event Timeline

dp created this revision.Apr 12 2019, 10:09 AM
This revision is now accepted and ready to land.Apr 15 2019, 7:10 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2019, 9:54 AM