llvm-project/llvm/lib/Transforms/InstCombine
Nikita Popov 36e03ac6ee [InstCombine] Fix negative GEP offset evaluation for 32-bit pointers
This fixes https://bugs.llvm.org/show_bug.cgi?id=39908.

The evaluateGEPOffsetExpression() function simplifies GEP offsets for
use in comparisons against zero, basically by converting X*Scale+Offset==0
to X+Offset/Scale==0 if Scale divides Offset. However, before this is done,
Offset is masked down to the pointer size. This results in incorrect
results for negative Offsets, because we basically end up dividing the
32-bit offset *zero* extended to 64-bit bits (rather than sign extended).

Fix this by explicitly sign extending the truncated value.

Differential Revision: https://reviews.llvm.org/D55449

llvm-svn: 348987
2018-12-12 23:19:03 +00:00
..
CMakeLists.txt InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineAddSub.cpp [InstCombine] name change: foldShuffledBinop -> foldVectorBinop; NFC 2018-10-03 15:20:58 +00:00
InstCombineAndOrXor.cpp [CmpInstAnalysis] fix function signature for ICmp code to predicate; NFC 2018-12-04 18:53:27 +00:00
InstCombineCalls.cpp [InstCombine] try to convert x86 movmsk intrinsic to generic IR (PR39927) 2018-12-11 16:38:03 +00:00
InstCombineCasts.cpp [InstCombine] fix rotate narrowing bug for non-pow-2 types 2018-11-15 17:19:14 +00:00
InstCombineCompares.cpp [InstCombine] Fix negative GEP offset evaluation for 32-bit pointers 2018-12-12 23:19:03 +00:00
InstCombineInternal.h [InstCombine] add helper for icmp with dominator; NFC 2018-12-04 15:35:17 +00:00
InstCombineLoadStoreAlloca.cpp [InstCombine] Set debug loc on `mergeStoreIntoSuccessor` phi 2018-11-19 19:55:02 +00:00
InstCombineMulDivRem.cpp Add a emitUnaryFloatFnCall version that fetches the function name from TLI 2018-10-18 06:27:53 +00:00
InstCombinePHI.cpp Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFC 2018-10-19 06:12:02 +00:00
InstCombineSelect.cpp [InstSimplify] fold select with implied condition 2018-11-29 18:44:39 +00:00
InstCombineShifts.cpp [InstCombine] Ensure nested shifts are in range (OSS-Fuzz #9880) 2018-11-06 11:28:22 +00:00
InstCombineSimplifyDemanded.cpp Revert r347871 "Fix: Add support for TFE/LWE in image intrinsic" 2018-11-29 20:14:17 +00:00
InstCombineTables.td InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineVectorOps.cpp InstCombine: Scalarize single use icmp/fcmp 2018-12-10 21:50:54 +00:00
InstructionCombining.cpp [InstCombine] fix undef propagation bug with shuffle+binop 2018-12-03 21:15:17 +00:00
LLVMBuild.txt