https://bugs.llvm.org/show_bug.cgi?id=44102
Bug ID: 44102
Summary: Missed canonicalizations for losslessness checks of
signed integer demotions
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: lebedev...@gmail.com
CC: llvm-bugs@lists.llvm.org
Much like https://bugs.llvm.org/show_bug.cgi?id=44100
we have a missed canonicalization for signed pattern:
Given
signed short t4(signed short x) {
x+=1;
return x;
}
signed short t5(signed short x) {
x-=1;
return x;
}
With -fsanitize=implicit-conversion we produce:
%2 = sext i16 %0 to i32, !dbg !15
%5 = add nsw i32 %2, 32769, !dbg !15
%6 = icmp ult i32 %5, 65536, !dbg !15
and
%2 = sext i16 %0 to i32, !dbg !22
%5 = add nsw i32 %2, 32767, !dbg !22
%6 = icmp ult i32 %5, 65536, !dbg !22
https://godbolt.org/z/eyc6qN
But in these cases we can simply check the original %0:
Name: sext-signed-trunc-check - increment
Pre: C2 == 65536 && C1 == (C2/2)+C3 && C3 > 0 && C3 u<= C2
%ZZ_IGNOREME = C3
%conv = sext i16 %x to i32
%zz = add i32 %conv, C1
%cmp = icmp ult i32 %zz, C2
=>
%ZZ_IGNOREME = C3
%cmp = icmp slt i16 %x, (trunc (C2/2) - trunc (C3))
Name: sext-signed-trunc-check - decrement
Pre: C2 == 65536 && C1 == (C2/2)+C3 && C3 < 0 && C3 > -C2
%ZZ_IGNOREME = C3
%conv = sext i16 %x to i32
%zz = add i32 %conv, C1
%cmp = icmp ult i32 %zz, C2
=>
%ZZ_IGNOREME = C3
%cmp = icmp sge i16 %x, (-(trunc (C2/2)) - (trunc (C3)))
https://rise4fun.com/Alive/GC57
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs