Fix PR33514

Summary:
The bug was uncovered after fix of  PR23384 (part 3 of 3).
The patch restricts pointer multiplication in SCEV computaion for ICmpZero.

Reviewers: qcolombet

Differential Revision: http://reviews.llvm.org/D36170

From: Evgeny Stupachenko <evstupac@gmail.com>
                         <evgeny.v.stupachenko@intel.com>
llvm-svn: 310092
This commit is contained in:
Evgeny Stupachenko 2017-08-04 18:46:13 +00:00
parent 0c079d06d3
commit 38197c66a1
2 changed files with 8 additions and 1 deletions

View File

@ -3672,6 +3672,12 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
// Don't do this if there is more than one offset.
if (LU.MinOffset != LU.MaxOffset) return;
// Check if transformation is valid. It is illegal to multiply pointer.
if (Base.ScaledReg && Base.ScaledReg->getType()->isPointerTy())
return;
for (const SCEV *BaseReg : Base.BaseRegs)
if (BaseReg->getType()->isPointerTy())
return;
assert(!Base.BaseGV && "ICmpZero use is not legal!");
// Check each interesting stride.

View File

@ -45,6 +45,7 @@ try.cont: ; preds = %for.end
; CHECK-LABEL: define void @b_copy_ctor(
; CHECK: catchpad
; CHECK-NEXT: icmp eq %struct.L
; CHECK-NEXT: getelementptr {{.*}} i64 sub (i64 0, i64 ptrtoint (%struct.L* @GV2 to i64))
; CHECK-NEXT: %4 = sub i64 0, %1
; CHECK-NEXT: getelementptr {{.*}} getelementptr inbounds (%struct.L, %struct.L* @GV2, i32 0, i32 0), i64 %4
declare void @a_copy_ctor()