
The original commit ( fe1f3cfc2669 ) was reverted because it could crash / assert when trying to fold a value that was replaced by a constant. In that case, there might not be an entry for the constant in the solver yet. This version adds a check for that possibility along with tests to exercise that pattern (they used to crash). Original commit message: This extends the transform added with D81756 to handle div/rem opcodes. For example: https://alive2.llvm.org/ce/z/cX6za6 This replicates part of what CVP already does, but the motivating example from issue #57472 demonstrates a phase ordering problem - we convert branches to select before CVP runs and miss the transform. Differential Revision: https://reviews.llvm.org/D133198
25 lines
611 B
LLVM
25 lines
611 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -passes=ipsccp -S < %s | FileCheck %s
|
|
|
|
@g = internal global i32 42, align 4
|
|
|
|
define i32 @sdiv_const_undef() {
|
|
; CHECK-LABEL: @sdiv_const_undef(
|
|
; CHECK-NEXT: [[D:%.*]] = sdiv i32 42, poison
|
|
; CHECK-NEXT: ret i32 [[D]]
|
|
;
|
|
%i = load i32, ptr @g, align 4
|
|
%d = sdiv i32 %i, poison
|
|
ret i32 %d
|
|
}
|
|
|
|
define i32 @sdiv_undef_const() {
|
|
; CHECK-LABEL: @sdiv_undef_const(
|
|
; CHECK-NEXT: [[D:%.*]] = sdiv i32 poison, 42
|
|
; CHECK-NEXT: ret i32 [[D]]
|
|
;
|
|
%i = load i32, ptr @g, align 4
|
|
%d = sdiv i32 poison, %i
|
|
ret i32 %d
|
|
}
|