https://bugs.llvm.org/show_bug.cgi?id=46234
Bug ID: 46234
Summary: [Middle-end] Moving truncate before right-shift
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
int src(long int num) {
num &= 0xFFFFFFF;
return num >> 2;
}
int tgt(long int num) {
return (((unsigned int)num) << 4) >> 6;
}
----------------------------------------
define i32 @src(i64 %0) {
%1:
%2 = lshr i64 %0, 2
%3 = trunc i64 %2 to i32
%4 = and i32 %3, 67108863
ret i32 %4
}
=>
define i32 @tgt(i64 %0) {
%1:
%2 = trunc i64 %0 to i32
%3 = lshr i32 %2, 2
%4 = and i32 %3, 67108863
ret i32 %4
}
Transformation seems to be correct!
https://godbolt.org/z/V7xRAy
^ we do that in backend, but not middle-end.
--
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