Nikita Popov 10f315dc9c
[ConstantFolding] Infer getelementptr nuw flag (#119214)
Infer nuw from nusw and nneg. This is the constant expression variant of
https://github.com/llvm/llvm-project/pull/111144.

Proof: https://alive2.llvm.org/ce/z/ihztLy
2024-12-09 16:44:05 +01:00

22 lines
701 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instcombine -S %s | FileCheck %s
@g1 = external global i16
@g2 = external global i16
define float @patatino() {
; CHECK-LABEL: @patatino(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr getelementptr inbounds nuw (i8, ptr @g2, i64 2), @g1
; CHECK-NEXT: [[FMUL:%.*]] = uitofp i1 [[CMP]] to float
; CHECK-NEXT: ret float [[FMUL]]
;
%cmp = icmp eq ptr getelementptr inbounds (i16, ptr @g2, i64 1), @g1
%uitofp1 = uitofp i1 %cmp to float
%uitofp2 = uitofp i1 %cmp to float
%fmul = fmul float %uitofp1, %uitofp2
%call = call float @fabsf(float %fmul)
ret float %call
}
declare float @fabsf(float)