llvm.org GIT mirror llvm / b226159
ARM: don't mangle DAG constant if it has more than one use The basic optimisation was to convert (mul $LHS, $complex_constant) into roughly "(shl (mul $LHS, $simple_constant), $simple_amt)" when it was expected to be cheaper. The original logic checks that the mul only has one use (since we're mangling $complex_constant), but when used in even more complex addressing modes there may be an outer addition that can pick up the wrong value too. I *think* the ARM addressing-mode problem is actually unreachable at the moment, but that depends on complex assessments of the profitability of pre-increment addressing modes so I've put a real check in there instead of an assertion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259228 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 4 years ago
2 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
746746
747747 // If Offset is a multiply-by-constant and it's profitable to extract a shift
748748 // and use it in a shifted operand do so.
749 if (Offset.getOpcode() == ISD::MUL) {
749 if (Offset.getOpcode() == ISD::MUL && N.hasOneUse()) {
750750 unsigned PowerOfTwo = 0;
751751 SDValue NewMulConst;
752752 if (canExtractShiftFromMul(Offset, 31, PowerOfTwo, NewMulConst)) {
14211421
14221422 // If OffReg is a multiply-by-constant and it's profitable to extract a shift
14231423 // and use it in a shifted operand do so.
1424 if (OffReg.getOpcode() == ISD::MUL) {
1424 if (OffReg.getOpcode() == ISD::MUL && N.hasOneUse()) {
14251425 unsigned PowerOfTwo = 0;
14261426 SDValue NewMulConst;
14271427 if (canExtractShiftFromMul(OffReg, 3, PowerOfTwo, NewMulConst)) {
238238 store i32 %add, i32* %addr
239239 ret void
240240 }
241
242 define { i32, i32 } @test_multi_use_add(i32 %base, i32 %offset) {
243 ; CHECK-LABEL: test_multi_use_add:
244 ; CHECK-THUMB: movs [[CONST:r[0-9]+]], #28
245 ; CHECK-THUMB: movt [[CONST]], #1
246
247 %prod = mul i32 %offset, 65564
248 %sum = add i32 %base, %prod
249
250 %ptr = inttoptr i32 %sum to i32*
251 %loaded = load i32, i32* %ptr
252
253 %ret.tmp = insertvalue { i32, i32 } undef, i32 %sum, 0
254 %ret = insertvalue { i32, i32 } %ret.tmp, i32 %loaded, 1
255
256 ret { i32, i32 } %ret
257 }