Files
clang-p2996/llvm/test/Bitcode/flags.ll
elhewaty 7d3924cee3 [IR] Add nowrap flags for trunc instruction (#85592)
This patch adds the nuw (no unsigned wrap) and nsw (no signed wrap)
poison-generating flags to the trunc instruction.

Discourse thread:
https://discourse.llvm.org/t/rfc-add-nowrap-flags-to-trunc/77453
2024-03-29 14:08:49 +08:00

54 lines
2.0 KiB
LLVM

; RUN: llvm-as < %s | llvm-dis > %t0
; RUN: opt -S < %s > %t1
; RUN: diff %t0 %t1
; RUN: verify-uselistorder < %s
; PR6140
; Make sure the flags are serialized/deserialized properly for both
; forward and backward references.
define void @foo() nounwind {
entry:
br label %first
second: ; preds = %first
%u = add nuw i32 %a, 0 ; <i32> [#uses=0]
%s = add nsw i32 %a, 0 ; <i32> [#uses=0]
%us = add nuw nsw i32 %a, 0 ; <i32> [#uses=0]
%z = add i32 %a, 0 ; <i32> [#uses=0]
%hh = zext nneg i32 %a to i64
%ll = zext i32 %s to i64
%jj = or disjoint i32 %a, 0
%oo = or i32 %a, 0
%tu = trunc nuw i32 %a to i16
%ts = trunc nsw i32 %a to i16
%tus = trunc nuw nsw i32 %a to i16
%t = trunc i32 %a to i16
%tuv = trunc nuw <2 x i32> %aa to <2 x i16>
%tsv = trunc nsw <2 x i32> %aa to <2 x i16>
%tusv = trunc nuw nsw <2 x i32> %aa to <2 x i16>
%tv = trunc <2 x i32> %aa to <2 x i16>
unreachable
first: ; preds = %entry
%aa = bitcast <2 x i32> <i32 0, i32 0> to <2 x i32>
%a = bitcast i32 0 to i32 ; <i32> [#uses=8]
%uu = add nuw i32 %a, 0 ; <i32> [#uses=0]
%ss = add nsw i32 %a, 0 ; <i32> [#uses=0]
%uuss = add nuw nsw i32 %a, 0 ; <i32> [#uses=0]
%zz = add i32 %a, 0 ; <i32> [#uses=0]
%kk = zext nneg i32 %a to i64
%rr = zext i32 %ss to i64
%mm = or disjoint i32 %a, 0
%nn = or i32 %a, 0
%tuu = trunc nuw i32 %a to i16
%tss = trunc nsw i32 %a to i16
%tuss = trunc nuw nsw i32 %a to i16
%tt = trunc i32 %a to i16
%ttuv = trunc nuw <2 x i32> %aa to <2 x i16>
%ttsv = trunc nsw <2 x i32> %aa to <2 x i16>
%ttusv = trunc nuw nsw <2 x i32> %aa to <2 x i16>
%ttv = trunc <2 x i32> %aa to <2 x i16>
br label %second
}