llvm.org GIT mirror llvm / a0711e6
[InstSimplify] add tests for known-not-a-power-of-2; NFC I added a canonicalization to create this general pattern in: rL363956 But as noted in PR42314: https://bugs.llvm.org/show_bug.cgi?id=42314#c11 ...we have a (potentially expensive) simplification for the version of the code that we just canonicalized away from, so we should add/adjust that code to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363981 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 months ago
1 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8686 %nege = sub i64 0, %e
8787 %e2 = and i64 %e, %nege
8888 ret i64 %e2
89 }
90
91 ; Power-of-2-or-zero value has no bits in common with its decrement.
92
93 define i32 @pow2_decrement(i32 %p) {
94 ; CHECK-LABEL: @pow2_decrement(
95 ; CHECK-NEXT: [[X:%.*]] = shl i32 1, [[P:%.*]]
96 ; CHECK-NEXT: [[A:%.*]] = add i32 [[X]], -1
97 ; CHECK-NEXT: [[R:%.*]] = and i32 [[A]], [[X]]
98 ; CHECK-NEXT: ret i32 [[R]]
99 ;
100 %x = shl i32 1, %p
101 %a = add i32 %x, -1
102 %r = and i32 %a, %x
103 ret i32 %r
104 }
105
106 define <2 x i32> @pow2_decrement_commute_vec(<2 x i32> %p) {
107 ; CHECK-LABEL: @pow2_decrement_commute_vec(
108 ; CHECK-NEXT: [[X:%.*]] = and <2 x i32> [[P:%.*]],
109 ; CHECK-NEXT: [[A:%.*]] = add <2 x i32> [[X]],
110 ; CHECK-NEXT: [[R:%.*]] = and <2 x i32> [[X]], [[A]]
111 ; CHECK-NEXT: ret <2 x i32> [[R]]
112 ;
113 %x = and <2 x i32> %p,
114 %a = add <2 x i32> %x,
115 %r = and <2 x i32> %x, %a
116 ret <2 x i32> %r
89117 }
90118
91119 define i1 @and_of_icmps0(i32 %b) {