llvm-project/llvm/lib/CodeGen/GlobalISel
Lucas Prates 283f5a198a [GlobalISel] Fix incorrect sign extension when combining G_INTTOPTR and G_PTR_ADD
The GlobalISel combiner currently uses sign extension when manipulating
the LHS constant when combining a sequence of the following sequence of
machine instructions into a single constant:
```
  %0:_(s32) = G_CONSTANT i32 <CONSTANT>
  %1:_(p0) = G_INTTOPTR %0:_(s32)
  %2:_(s64) = G_CONSTANT i64 <CONSTANT>
  %3:_(p0) = G_PTR_ADD %1:_, %2:_(s64)
```

This causes an issue when the bit width of the first contant and the
target pointer size are different, as G_INTTOPTR has no sign extension
semantics.

This patch fixes this by capture an arbitrary precision in when matching
the constant, allowing the matching function to correctly zero extend
it.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D116941
2022-01-20 17:02:52 +00:00
..
CMakeLists.txt [GlobalISel] Add a store-merging optimization pass and enable for AArch64. 2021-11-15 21:10:39 -08:00
CSEInfo.cpp [GISel] Print better error messages for missing Combiner Observer calls 2021-07-01 15:18:18 -07:00
CSEMIRBuilder.cpp GlobalISel: Fix CSEMIRBuilder mishandling constant folds of vectors 2022-01-18 17:21:02 -05:00
CallLowering.cpp Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction" 2022-01-14 04:50:07 +00:00
Combiner.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
CombinerHelper.cpp [GlobalISel] Fix incorrect sign extension when combining G_INTTOPTR and G_PTR_ADD 2022-01-20 17:02:52 +00:00
GISelChangeObserver.cpp
GISelKnownBits.cpp Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction" 2022-01-14 04:50:07 +00:00
GlobalISel.cpp [GlobalISel] Add a store-merging optimization pass and enable for AArch64. 2021-11-15 21:10:39 -08:00
IRTranslator.cpp [GlobalISel] Fix IRTranslator for constexpr fcmp 2021-12-10 08:49:12 +01:00
InlineAsmLowering.cpp [IR] Add ConstraintInfo::hasArg() helper (NFC) 2022-01-07 10:44:38 +01:00
InstructionSelect.cpp GlobalISel: Always enable GISelKnownBits for InstructionSelect 2022-01-12 18:57:24 -05:00
InstructionSelector.cpp [llvm] Remove redundant member initialization (NFC) 2022-01-07 17:45:09 -08:00
LegacyLegalizerInfo.cpp [GlobalISel] NFC: Change LLT::vector to take ElementCount. 2021-06-24 11:26:12 +01:00
LegalityPredicates.cpp [AMDGPU][GlobalISel] Legalize G_MUL for non-standard types 2021-09-07 16:33:24 +02:00
LegalizeMutations.cpp [AMDGPU][GlobalISel] Legalize G_MUL for non-standard types 2021-09-07 16:33:24 +02:00
Legalizer.cpp [GlobalISel] Improve elimination of dead instructions in legalizer 2021-09-20 13:00:58 +02:00
LegalizerHelper.cpp [NFC] Test commit to verify commit access. 2022-01-18 18:03:26 -08:00
LegalizerInfo.cpp [GlobalISel] Add convenience constructors to MemDesc 2021-09-03 12:52:18 +02:00
LoadStoreOpt.cpp [CodeGen] Use range-based for loops (NFC) 2021-12-03 20:45:59 -08:00
Localizer.cpp GlobalISel: Fix insert point in localizer 2022-01-12 13:44:05 -05:00
LostDebugLocObserver.cpp
MachineIRBuilder.cpp Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction" 2022-01-14 04:50:07 +00:00
RegBankSelect.cpp Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction" 2022-01-14 04:50:07 +00:00
RegisterBank.cpp [GlobalISel] Use ListSeparator (NFC) 2021-02-04 21:18:04 -08:00
RegisterBankInfo.cpp [LLVM][NFC]Inclusive language: remove occurances of sanity check/test from llvm 2021-11-24 17:29:55 -05:00
Utils.cpp GlobalISel: Swap order of operand checks in ConstantFoldVectorBinop 2022-01-18 17:21:02 -05:00