[GlobalISel] LegalizerHelper - Extract widenScalarAddoSubo method
authorCassie Jones <code@witchoflight.com>
Fri, 22 Jan 2021 21:36:58 +0000 (13:36 -0800)
committerAmara Emerson <amara@apple.com>
Fri, 22 Jan 2021 22:08:46 +0000 (14:08 -0800)
commit2bb92bf451d7eb2c817f3e5403353e7c0c14d350
treea6e95adc341318d69761b920403a1c96c9ff8084
parent607e5a5000bddec24061b54a7e7955d51fe0d049
[GlobalISel] LegalizerHelper - Extract widenScalarAddoSubo method

The widenScalar implementation for signed and unsigned overflowing
operations were very similar: both are checked by truncating the result
and then re-sign/zero-extending it and checking that it matches the
computed operation.

Using a truncate + zero-extend for the unsigned case instead of manually
producing the AND instruction like before leads to an extra copy
instruction during legalization, but this should be harmless.

Differential Revision: https://reviews.llvm.org/D95035
llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-add.mir
llvm/test/CodeGen/AArch64/GlobalISel/legalize-sub.mir
llvm/test/CodeGen/AArch64/legalize-uaddo.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uaddo.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-usubo.mir
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp