This is an archive of the discontinued LLVM Phabricator instance.

[mips][microMIPS] Fix an issue with selecting sqrt instruction in LLVM backend
ClosedPublic

Authored by zbuljan on Sep 29 2015, 1:56 AM.

Details

Summary

7 tests failed during fast LLVM test-suite run:

  • MultiSource/Benchmarks/McCat/18-imp/imp
  • MultiSource/Applications/oggenc/oggenc
  • MultiSource/Benchmarks/MallocBench/gs/gs
  • MultiSource/Benchmarks/MiBench/automotive-susan/automotive-susan
  • MultiSource/Benchmarks/VersaBench/beamformer/beamformer
  • MultiSource/Benchmarks/MiBench/consumer-lame/consumer-lame
  • MultiSource/Benchmarks/Bullet/bullet

Error message was in the form of:
fatal error: error in backend: Cannot select: 0x95c3288: f32 = fsqrt 0x95c0190 [ORD=9] [ID=18]

0x95c0190: f32 = fadd 0x95bef30, 0x95c4d00 [ORD=8] [ID=17]
  0x95bef30: f32 = fmul 0x95c4988, 0x95c4988 [ORD=5] [ID=16]

...

There was problem with selecting sqrt instruction in LLVM backend.

To fix the issue changes are made in TableGen definition for sqrt instruction in MipsInstrFPU.td and new test file sqrt.ll is added to LLVM regression tests.

Diff Detail

Repository
rL LLVM

Event Timeline

zbuljan updated this revision to Diff 35944.Sep 29 2015, 1:56 AM
zbuljan retitled this revision from to [mips][microMIPS] Fix an issue with selecting sqrt instruction.
zbuljan updated this object.
zbuljan added subscribers: petarj, llvm-commits.
dsanders requested changes to this revision.Sep 30 2015, 3:21 AM
dsanders edited edge metadata.

[mips][microMIPS] Fix an issue with selecting sqrt instruction
This patch fixes bug 2206 (https://dmz-portal.mips.com/bugz/show_bug.cgi?id=2206).

Could you rephrase the subject and summary to explain the problem rather than linking to the MIPS internal bugzilla? The LLVM commit messages should stand on their own and shouldn't depend on external sources to understand the problem/solution in case that information becomes inaccessible for some reason. In this case the linked ticket doesn't explain the problem either, it just says 'Several micromips builders started to fail'. I had to dig through several links to get to the buildbot log in order to figure out what kind of problem it was.

lib/Target/Mips/MipsInstrFPU.td
356–357 ↗(On Diff #35944)

I notice you've added StdMMR6Rel but your test doesn't try microMIPS32R6. Could you add that to the test?

test/CodeGen/Mips/sqrt.ll
12 ↗(On Diff #35944)

This check needs to be stricter. It will currently match 'sqrt_fn:', 'sqrtf:', etc. in the output even if the intended test fails.

Also, could you put it with the IR tests in test/CodeGen/Mips/llvm-ir/? The test is the same kind of single-IR-statement test as those.

This revision now requires changes to proceed.Sep 30 2015, 3:21 AM
zbuljan updated this revision to Diff 36337.Oct 2 2015, 3:17 AM
zbuljan retitled this revision from [mips][microMIPS] Fix an issue with selecting sqrt instruction to [mips][microMIPS] Fix an issue with selecting sqrt instruction in LLVM backend.
zbuljan updated this object.
zbuljan edited edge metadata.

Added new RUN line for microMIPS32R6 test.
Added CHECK-NO to restrict maching of sqrt.
sqrt.ll is moved to test/CodeGen/Mips/llvm-ir folder.

Thanks. The new commit message is a lot better but I need to re-iterate one important point.

Problem was reported on bugzilla as bug 2206.

Most people would read this as referring to https://llvm.org/PR2206 but the solution isn't to link to our internal bugzilla. The key point was that our internal bugzilla tickets mean nothing to the wider LLVM community. Please drop this sentence.


LGTM with our internal bugzilla reference removed and the test case fixed.

test/CodeGen/Mips/llvm-ir/sqrt.ll
13–15 ↗(On Diff #36337)

The CHECK-NOT doesn't quite achieve what you intended. Consider:

sqrt_fn:
  ...
  jal sqrtf

The CHECK-LABEL will match the sqrt_fn: as intended, the CHECK will match the 'sqrt' in 'jal sqrtf'. After these two matches are made, the CHECK-NOT will check that sqrtf doesn't match between the other two matches. This will successfully find zero matches and the test will mistakenly pass.

I'd just add the registers to the instruction I want to match like so:

; CHECK: sqrt $f0, $f12

with that, no CHECK-LABEL or CHECK-NOT is necessary.

zbuljan added inline comments.Oct 2 2015, 4:39 AM
test/CodeGen/Mips/llvm-ir/sqrt.ll
13–15 ↗(On Diff #36337)

In this case, I think, there should be sqrt.s in expression:
; CHECK: sqrt.s $f0, $f12

In this case, I think, there should be sqrt.s in expression:

I agree.

zbuljan updated this revision to Diff 36347.Oct 2 2015, 5:33 AM
zbuljan updated this object.
zbuljan edited edge metadata.

Removed summary line that references bugzilla.
Updated CHECK line with sqrt instruction: chaged to sqrt.s and added registers.
Removed unnecessary CHECK lines from .ll file.

dsanders accepted this revision.Oct 2 2015, 5:39 AM
dsanders edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 2 2015, 5:39 AM
This revision was automatically updated to reflect the committed changes.