This is an archive of the discontinued LLVM Phabricator instance.

Fix mapping of @llvm.arm.ssat/usat intrinsics to ssat/usat instructions
ClosedPublic

Authored by rmaprath on Oct 19 2015, 2:14 AM.

Details

Summary

The mapping of these two intrinsics in ARMInstrInfo.td had a small omission which lead to their operands not being validated/transformed before being lowered into usat and ssat instructions. This can cause incorrect instructions to be emitted.

I've also added tests for the remaining two saturating arithmetic intrinsics @llvm.arm.qadd and @llvm.arm.qsub as they are missing codegen tests.

Diff Detail

Event Timeline

rmaprath updated this revision to Diff 37727.Oct 19 2015, 2:14 AM
rmaprath retitled this revision from to Fix mapping of @llvm.arm.ssat/usat intrinsics to ssat/usat instructions.
rmaprath updated this object.
rmaprath added reviewers: jmolloy, olista01.
rmaprath set the repository for this revision to rL LLVM.
rmaprath added a subscriber: llvm-commits.

Shouldn't the tests account for the corner cases and validation errors as well?

Shouldn't the tests account for the corner cases and validation errors as well?

I did think about this, but couldn't find a way to add such tests. If I put out-of-rage arguments for the intrinsics, instruction selection aborts with:

Script:
--
/work/oss/git/build/./bin/llc -O1 -mtriple=armv6-none-none-eabi /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll -o - | /work/oss/git/build/./bin/FileCheck /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll
--
Exit Code: 2

Command Output (stderr):
--
LLVM ERROR: Cannot select: intrinsic %llvm.arm.ssat
FileCheck error: '-' is empty.

--

And that completely kills the test (no further tests will execute). Any suggestions?

Thanks.

/work/oss/git/build/./bin/llc -O1 -mtriple=armv6-none-none-eabi /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll -o - | /work/oss/git/build/./bin/FileCheck /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll

You have to separate the good tests from the bad ones in different files. The good ones, you do just like the one you have (but expand to the limits of the ranges accepted). The bad ones, just replace:

; RUN: llc ...

for

; RUN: not llc ...

and you'll be able to use FileCheck to parse the error messages.

There are many tests in CodeGen that follow this pattern.

/work/oss/git/build/./bin/llc -O1 -mtriple=armv6-none-none-eabi /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll -o - | /work/oss/git/build/./bin/FileCheck /work/oss/git/src/test/CodeGen/ARM/sat-arith.ll

You have to separate the good tests from the bad ones in different files. The good ones, you do just like the one you have (but expand to the limits of the ranges accepted). The bad ones, just replace:

; RUN: llc ...

for

; RUN: not llc ...

and you'll be able to use FileCheck to parse the error messages.

There are many tests in CodeGen that follow this pattern.

Thanks! I'll add the tests.

rmaprath updated this revision to Diff 37732.Oct 19 2015, 3:39 AM
rmaprath removed rL LLVM as the repository for this revision.

Updated patch to test the corner cases of ssat/usat intrinsics. qadd/qsub are not affected as they don't take in an immediate with range restrictions.

rengolin accepted this revision.Oct 19 2015, 3:49 AM
rengolin added a reviewer: rengolin.

Looks good. Thanks!

This revision is now accepted and ready to land.Oct 19 2015, 3:49 AM
rmaprath closed this revision.Oct 19 2015, 4:47 AM

Thanks. Committed as r250697.