As part of making ScalarEvolution's handling of pointers consistent, we want to forbid multiplying a pointer by -1 (or any other value). This means we can't blindly subtract pointers. There are a few ways we could deal with this: 1. We could completely forbid subtracting pointers in getMinusSCEV() 2. We could forbid subracting pointers with different pointer bases (this patch). 3. We could try to ptrtoint pointer operands. The option in this patch is more friendly to non-integral pointers: code that works with normal pointers will also work with non-integral pointers. And it seems like there are very few places that actually benefit from the third option. As a minimal patch, the ScalarEvolution implementation of getMinusSCEV still ends up subtracting pointers if they have the same base. This should eliminate the shared pointer base, but eventually we'll need to rewrite it to avoid negating the pointer base. I plan to do this as a separate step to allow measuring the compile-time impact. This doesn't cause obvious functional changes in most cases; the one case that is significantly affected is ICmpZero handling in LSR (which is the source of almost all the test changes). The resulting changes seem okay to me, but suggestions welcome. As an alternative, I tried explicitly ptrtoint'ing the operands, but the result doesn't seem obviously better. I deleted the test lsr-undef-in-binop.ll becuase I couldn't figure out how to repair it to test what it was actually trying to test. Recommitting with fix to MemoryDepChecker::isDependent. Differential Revision: https://reviews.llvm.org/D104806
54 lines
1.6 KiB
LLVM
54 lines
1.6 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 < %s | FileCheck %s
|
|
|
|
define void @f(i8*, i8*, i64*) {
|
|
; Check we don't assert and this is not a Hardware Loop
|
|
; CHECK-LABEL: f:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: cmpld 3, 4
|
|
; CHECK-NEXT: beqlr 0
|
|
; CHECK-NEXT: # %bb.1:
|
|
; CHECK-NEXT: not 3, 3
|
|
; CHECK-NEXT: add 3, 3, 4
|
|
; CHECK-NEXT: li 4, 15
|
|
; CHECK-NEXT: cmpldi 3, 15
|
|
; CHECK-NEXT: isellt 3, 3, 4
|
|
; CHECK-NEXT: addi 4, 3, 1
|
|
; CHECK-NEXT: ld 3, 8(5)
|
|
; CHECK-NEXT: mtctr 4
|
|
; CHECK-NEXT: .p2align 4
|
|
; CHECK-NEXT: .LBB0_2:
|
|
; CHECK-NEXT: sldi 3, 3, 4
|
|
; CHECK-NEXT: bdnz .LBB0_2
|
|
; CHECK-NEXT: # %bb.3:
|
|
; CHECK-NEXT: std 3, 8(5)
|
|
; CHECK-NEXT: blr
|
|
|
|
%4 = icmp eq i8* %0, %1
|
|
br i1 %4, label %9, label %5
|
|
|
|
5: ; preds = %3
|
|
%6 = getelementptr inbounds i64, i64* %2, i64 1
|
|
%7 = load i64, i64* %6, align 8
|
|
br label %10
|
|
|
|
8: ; preds = %10
|
|
store i64 %14, i64* %6, align 8
|
|
br label %9
|
|
|
|
9: ; preds = %8, %3
|
|
ret void
|
|
|
|
10: ; preds = %5, %10
|
|
%11 = phi i64 [ %7, %5 ], [ %14, %10 ]
|
|
%12 = phi i32 [ 0, %5 ], [ %15, %10 ]
|
|
%13 = phi i8* [ %0, %5 ], [ %16, %10 ]
|
|
%14 = shl nsw i64 %11, 4
|
|
%15 = add nuw nsw i32 %12, 1
|
|
%16 = getelementptr inbounds i8, i8* %13, i64 1
|
|
%17 = icmp ugt i32 %12, 14
|
|
%18 = icmp eq i8* %16, %1
|
|
%19 = or i1 %18, %17
|
|
br i1 %19, label %8, label %10
|
|
}
|