[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2019-01-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri abandoned this revision.
lebedev.ri added a comment.

As disscussed in D54653  
(https://reviews.llvm.org/D54653#1318964),
this differential will be simply unneeded, that review will address the issue 
too, so abandoning.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54654/new/

https://reviews.llvm.org/D54654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

> As discussed on IRC, check sign/power of 2 correctly for the alignment 
> assumptions.

"As discussed on IRC" is not appropriate for a commit message. The rationale 
must be documented here.

> I hope that extra is-power-of-two won't confuse the optimizer.

Probably would unless it gets constant folded.


Repository:
  rC Clang

https://reviews.llvm.org/D54654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LG.
I hope that extra is-power-of-two won't confuse the optimizer.


Repository:
  rC Clang

https://reviews.llvm.org/D54654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Repository:
  rC Clang

https://reviews.llvm.org/D54654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: jyknight, craig.topper, lebedev.ri.

As discussed on IRC, check sign/power of 2 correctly for the
alignment assumptions.


Repository:
  rC Clang

https://reviews.llvm.org/D54654

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/alloc-align-attr.c

Index: test/CodeGen/alloc-align-attr.c
===
--- test/CodeGen/alloc-align-attr.c
+++ test/CodeGen/alloc-align-attr.c
@@ -8,9 +8,12 @@
   return *m1(a);
 // CHECK: call i32* @m1(i32 [[PARAM1:%[^\)]+]]) 
 // CHECK: [[ALIGNCAST1:%.+]] = sext i32 [[PARAM1]] to i64
-// CHECK: [[ISPOS1:%.+]] = icmp sgt i64 [[ALIGNCAST1]], 0
-// CHECK: [[POSMASK1:%.+]] = sub i64 [[ALIGNCAST1]], 1
-// CHECK: [[MASK1:%.+]] = select i1 [[ISPOS1]], i64 [[POSMASK1]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST1]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST1]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST1]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK1:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT1:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], [[MASK1]]
 // CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
@@ -23,9 +26,12 @@
 // CHECK: [[CONV2:%.+]] = trunc i64 %{{.+}} to i32
 // CHECK: call i32* @m1(i32 [[CONV2]])
 // CHECK: [[ALIGNCAST2:%.+]] = sext i32 [[CONV2]] to i64
-// CHECK: [[ISPOS2:%.+]] = icmp sgt i64 [[ALIGNCAST2]], 0
-// CHECK: [[POSMASK2:%.+]] = sub i64 [[ALIGNCAST2]], 1
-// CHECK: [[MASK2:%.+]] = select i1 [[ISPOS2]], i64 [[POSMASK2]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST2]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST2]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST2]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK2:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT2:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], [[MASK2]]
 // CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
@@ -39,9 +45,12 @@
   return *m2(a);
 // CHECK: [[CONV3:%.+]] = sext i32 %{{.+}} to i64
 // CHECK: call i32* @m2(i64 [[CONV3]])
-// CHECK: [[ISPOS3:%.+]] = icmp sgt i64 [[CONV3]], 0
-// CHECK: [[POSMASK3:%.+]] = sub i64 [[CONV3]], 1
-// CHECK: [[MASK3:%.+]] = select i1 [[ISPOS3]], i64 [[POSMASK3]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp ugt i64 [[CONV3]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[CONV3]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[CONV3]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK3:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT3:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], [[MASK3]]
 // CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
@@ -53,16 +62,18 @@
 // CHECK: define i32 @test4
   return *m2(a);
 // CHECK: call i32* @m2(i64 [[PARAM4:%[^\)]+]]) 
-// CHECK: [[ISPOS4:%.+]] = icmp sgt i64 [[PARAM4]], 0
-// CHECK: [[POSMASK4:%.+]] = sub i64 [[PARAM4]], 1
-// CHECK: [[MASK4:%.+]] = select i1 [[ISPOS4]], i64 [[POSMASK4]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp ugt i64 [[PARAM4]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[PARAM4]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[PARAM4]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK4:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT4:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR4:%.+]] = and i64 [[PTRINT4]], [[MASK4]]
 // CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
 // CHECK: call void @llvm.assume(i1 [[MASKCOND4]])
 }
 
-
 struct Empty {};
 struct MultiArgs { __INT64_TYPE__ a, b;};
 // Struct parameter doesn't take up an IR parameter, 'i' takes up 2.
@@ -74,9 +85,12 @@
   return *m3(e, a);
 // CHECK: call i32* @m3(i64 %{{.*}}, i64 %{{.*}}) 
 // CHECK: [[ALIGNCAST5:%.+]] = trunc i128 %{{.*}} to i64
-// CHECK: [[ISPOS5:%.+]] = icmp sgt i64 [[ALIGNCAST5]], 0
-// CHECK: [[POSMASK5:%.+]] = sub i64 [[ALIGNCAST5]], 1
-// CHECK: [[MASK5:%.+]] = select i1 [[ISPOS5]], i64 [[POSMASK5]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST5]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST5]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST5]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK5:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT5:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR5:%.+]] = and i64