2015-03-05 02:43:29 +08:00
|
|
|
; "PLAIN" - No optimizations. This tests the default target layout
|
2010-02-02 02:27:38 +08:00
|
|
|
; constant folder.
|
2010-01-29 02:08:26 +08:00
|
|
|
; RUN: opt -S -o - < %s | FileCheck --check-prefix=PLAIN %s
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2015-03-05 02:43:29 +08:00
|
|
|
; "OPT" - Optimizations but no targetdata. This tests default target layout
|
2010-02-02 02:27:38 +08:00
|
|
|
; folding in the optimizers.
|
2010-01-29 02:08:26 +08:00
|
|
|
; RUN: opt -S -o - -instcombine -globalopt < %s | FileCheck --check-prefix=OPT %s
|
|
|
|
|
2010-02-02 02:27:38 +08:00
|
|
|
; "TO" - Optimizations and targetdata. This tests target-dependent
|
|
|
|
; folding in the optimizers.
|
|
|
|
; RUN: opt -S -o - -instcombine -globalopt -default-data-layout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" < %s | FileCheck --check-prefix=TO %s
|
|
|
|
|
2015-03-05 02:43:29 +08:00
|
|
|
; "SCEV" - ScalarEvolution with default target layout
|
2010-02-02 02:27:38 +08:00
|
|
|
; RUN: opt -analyze -scalar-evolution < %s | FileCheck --check-prefix=SCEV %s
|
|
|
|
|
|
|
|
|
2010-01-29 02:08:26 +08:00
|
|
|
; The automatic constant folder in opt does not have targetdata access, so
|
|
|
|
; it can't fold gep arithmetic, in general. However, the constant folder run
|
2010-02-02 02:27:38 +08:00
|
|
|
; from instcombine and global opt can use targetdata.
|
2010-01-29 02:08:26 +08:00
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: @G8 = global i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -1)
|
|
|
|
; PLAIN: @G1 = global i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -1)
|
|
|
|
; PLAIN: @F8 = global i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -2)
|
|
|
|
; PLAIN: @F1 = global i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -2)
|
|
|
|
; PLAIN: @H8 = global i8* getelementptr (i8, i8* null, i32 -1)
|
|
|
|
; PLAIN: @H1 = global i1* getelementptr (i1, i1* null, i32 -1)
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: @G8 = local_unnamed_addr global i8* null
|
|
|
|
; OPT: @G1 = local_unnamed_addr global i1* null
|
|
|
|
; OPT: @F8 = local_unnamed_addr global i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; OPT: @F1 = local_unnamed_addr global i1* inttoptr (i64 -1 to i1*)
|
|
|
|
; OPT: @H8 = local_unnamed_addr global i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; OPT: @H1 = local_unnamed_addr global i1* inttoptr (i64 -1 to i1*)
|
|
|
|
; TO: @G8 = local_unnamed_addr global i8* null
|
|
|
|
; TO: @G1 = local_unnamed_addr global i1* null
|
|
|
|
; TO: @F8 = local_unnamed_addr global i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; TO: @F1 = local_unnamed_addr global i1* inttoptr (i64 -1 to i1*)
|
|
|
|
; TO: @H8 = local_unnamed_addr global i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; TO: @H1 = local_unnamed_addr global i1* inttoptr (i64 -1 to i1*)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
@G8 = global i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -1)
|
|
|
|
@G1 = global i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -1)
|
|
|
|
@F8 = global i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -2)
|
|
|
|
@F1 = global i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -2)
|
|
|
|
@H8 = global i8* getelementptr (i8, i8* inttoptr (i32 0 to i8*), i32 -1)
|
|
|
|
@H1 = global i1* getelementptr (i1, i1* inttoptr (i32 0 to i1*), i32 -1)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
|
|
|
; The target-independent folder should be able to do some clever
|
|
|
|
; simplifications on sizeof, alignof, and offsetof expressions. The
|
|
|
|
; target-dependent folder should fold these down to constants.
|
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: @a = constant i64 mul (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2310)
|
|
|
|
; PLAIN: @b = constant i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64)
|
|
|
|
; PLAIN: @c = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2)
|
|
|
|
; PLAIN: @d = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 11)
|
|
|
|
; PLAIN: @e = constant i64 ptrtoint (double* getelementptr ({ double, float, double, double }, { double, float, double, double }* null, i64 0, i32 2) to i64)
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: @f = constant i64 1
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: @g = constant i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64)
|
|
|
|
; PLAIN: @h = constant i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)
|
|
|
|
; PLAIN: @i = constant i64 ptrtoint (i1** getelementptr ({ i1, i1* }, { i1, i1* }* null, i64 0, i32 1) to i64)
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: @a = local_unnamed_addr constant i64 18480
|
|
|
|
; OPT: @b = local_unnamed_addr constant i64 8
|
|
|
|
; OPT: @c = local_unnamed_addr constant i64 16
|
|
|
|
; OPT: @d = local_unnamed_addr constant i64 88
|
|
|
|
; OPT: @e = local_unnamed_addr constant i64 16
|
|
|
|
; OPT: @f = local_unnamed_addr constant i64 1
|
|
|
|
; OPT: @g = local_unnamed_addr constant i64 8
|
|
|
|
; OPT: @h = local_unnamed_addr constant i64 8
|
|
|
|
; OPT: @i = local_unnamed_addr constant i64 8
|
|
|
|
; TO: @a = local_unnamed_addr constant i64 18480
|
|
|
|
; TO: @b = local_unnamed_addr constant i64 8
|
|
|
|
; TO: @c = local_unnamed_addr constant i64 16
|
|
|
|
; TO: @d = local_unnamed_addr constant i64 88
|
|
|
|
; TO: @e = local_unnamed_addr constant i64 16
|
|
|
|
; TO: @f = local_unnamed_addr constant i64 1
|
|
|
|
; TO: @g = local_unnamed_addr constant i64 8
|
|
|
|
; TO: @h = local_unnamed_addr constant i64 8
|
|
|
|
; TO: @i = local_unnamed_addr constant i64 8
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
@a = constant i64 mul (i64 3, i64 mul (i64 ptrtoint ({[7 x double], [7 x double]}* getelementptr ({[7 x double], [7 x double]}, {[7 x double], [7 x double]}* null, i64 11) to i64), i64 5))
|
|
|
|
@b = constant i64 ptrtoint ([13 x double]* getelementptr ({i1, [13 x double]}, {i1, [13 x double]}* null, i64 0, i32 1) to i64)
|
|
|
|
@c = constant i64 ptrtoint (double* getelementptr ({double, double, double, double}, {double, double, double, double}* null, i64 0, i32 2) to i64)
|
|
|
|
@d = constant i64 ptrtoint (double* getelementptr ([13 x double], [13 x double]* null, i64 0, i32 11) to i64)
|
|
|
|
@e = constant i64 ptrtoint (double* getelementptr ({double, float, double, double}, {double, float, double, double}* null, i64 0, i32 2) to i64)
|
|
|
|
@f = constant i64 ptrtoint (<{ i16, i128 }>* getelementptr ({i1, <{ i16, i128 }>}, {i1, <{ i16, i128 }>}* null, i64 0, i32 1) to i64)
|
|
|
|
@g = constant i64 ptrtoint ({double, double}* getelementptr ({i1, {double, double}}, {i1, {double, double}}* null, i64 0, i32 1) to i64)
|
|
|
|
@h = constant i64 ptrtoint (double** getelementptr (double*, double** null, i64 1) to i64)
|
|
|
|
@i = constant i64 ptrtoint (double** getelementptr ({i1, double*}, {i1, double*}* null, i64 0, i32 1) to i64)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
|
|
|
; The target-dependent folder should cast GEP indices to integer-sized pointers.
|
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: @M = constant i64* getelementptr (i64, i64* null, i32 1)
|
|
|
|
; PLAIN: @N = constant i64* getelementptr ({ i64, i64 }, { i64, i64 }* null, i32 0, i32 1)
|
|
|
|
; PLAIN: @O = constant i64* getelementptr ([2 x i64], [2 x i64]* null, i32 0, i32 1)
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: @M = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
|
|
|
; OPT: @N = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
|
|
|
; OPT: @O = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: @M = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: @N = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: @O = local_unnamed_addr constant i64* inttoptr (i64 8 to i64*)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
@M = constant i64* getelementptr (i64, i64* null, i32 1)
|
|
|
|
@N = constant i64* getelementptr ({ i64, i64 }, { i64, i64 }* null, i32 0, i32 1)
|
|
|
|
@O = constant i64* getelementptr ([2 x i64], [2 x i64]* null, i32 0, i32 1)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2011-12-15 12:33:48 +08:00
|
|
|
; Fold GEP of a GEP. Very simple cases are folded without targetdata.
|
2010-03-11 03:31:51 +08:00
|
|
|
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: @Y = global [3 x { i32, i32 }]* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 2)
|
|
|
|
; PLAIN: @Z = global i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1)
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: @Y = local_unnamed_addr global [3 x { i32, i32 }]* getelementptr ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 2)
|
|
|
|
; OPT: @Z = local_unnamed_addr global i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
|
|
|
|
; TO: @Y = local_unnamed_addr global [3 x { i32, i32 }]* getelementptr ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 2)
|
|
|
|
; TO: @Z = local_unnamed_addr global i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
|
2010-03-11 03:31:51 +08:00
|
|
|
|
|
|
|
@ext = external global [3 x { i32, i32 }]
|
2015-03-14 02:20:45 +08:00
|
|
|
@Y = global [3 x { i32, i32 }]* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 1), i64 1)
|
|
|
|
@Z = global i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1)
|
2010-03-11 03:31:51 +08:00
|
|
|
|
2010-02-02 02:27:38 +08:00
|
|
|
; Duplicate all of the above as function return values rather than
|
|
|
|
; global initializers.
|
|
|
|
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i8* @goo8() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i1* @goo1() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i1* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i8* @foo8() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i1* @foo1() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i1* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i8* @hoo8() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i8* getelementptr (i8, i8* null, i32 -1) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i1* @hoo1() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i1* getelementptr (i1, i1* null, i32 -1) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i1* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
; PLAIN: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i8* @goo8() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i8* null
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i1* @goo1() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i1* null
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i8* @foo8() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i8* inttoptr (i64 -1 to i8*)
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i1* @foo1() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i1* inttoptr (i64 -1 to i1*)
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i8* @hoo8() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i8* inttoptr (i64 -1 to i8*)
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i1* @hoo1() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i1* inttoptr (i64 -1 to i1*)
|
2010-01-29 02:08:26 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i8* @goo8() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i8* null
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i1* @goo1() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i1* null
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i8* @foo8() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i1* @foo1() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i1* inttoptr (i64 -1 to i1*)
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i8* @hoo8() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i8* inttoptr (i64 -1 to i8*)
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i1* @hoo1() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i1* inttoptr (i64 -1 to i1*)
|
|
|
|
; TO: }
|
|
|
|
; SCEV: Classifying expressions for: @goo8
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> (-1 + inttoptr (i32 1 to i8*))
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @goo1
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> (-1 + inttoptr (i32 1 to i1*))
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @foo8
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> (-2 + inttoptr (i32 1 to i8*))
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @foo1
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> (-2 + inttoptr (i32 1 to i1*))
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @hoo8
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> -1
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @hoo1
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> -1
|
2010-01-29 02:08:26 +08:00
|
|
|
|
|
|
|
define i8* @goo8() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
|
|
|
define i1* @goo1() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i1* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
|
|
|
define i8* @foo8() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
|
|
|
define i1* @foo1() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i1* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
|
|
|
define i8* @hoo8() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i8* getelementptr (i8, i8* inttoptr (i32 0 to i8*), i32 -1) to i8*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i8* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
|
|
|
define i1* @hoo1() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i1* getelementptr (i1, i1* inttoptr (i32 0 to i1*), i32 -1) to i1*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i1* %t
|
|
|
|
}
|
|
|
|
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fa() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2310) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fb() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fc() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fd() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 11) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fe() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 ptrtoint (double* getelementptr ({ double, float, double, double }, { double, float, double, double }* null, i64 0, i32 2) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @ff() #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: %t = bitcast i64 1 to i64
|
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fg() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 09:41:39 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fh() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64) to i64
|
2010-02-10 14:13:07 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64 @fi() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64 ptrtoint (i1** getelementptr ({ i1, i1* }, { i1, i1* }* null, i64 0, i32 1) to i64) to i64
|
2010-02-26 00:45:19 +08:00
|
|
|
; PLAIN: ret i64 %t
|
|
|
|
; PLAIN: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fa() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 18480
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fb() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 8
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fc() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 16
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fd() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 88
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fe() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 16
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @ff() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: ret i64 1
|
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fg() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 8
|
2010-02-02 09:41:39 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fh() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 8
|
2010-02-10 14:13:07 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64 @fi() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64 8
|
2010-02-10 14:13:07 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fa() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 18480
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fb() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 8
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fc() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 16
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fd() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 88
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fe() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 16
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @ff() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64 1
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fg() local_unnamed_addr #0 {
|
2010-02-02 09:41:39 +08:00
|
|
|
; TO: ret i64 8
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fh() local_unnamed_addr #0 {
|
2010-02-10 14:13:07 +08:00
|
|
|
; TO: ret i64 8
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64 @fi() local_unnamed_addr #0 {
|
2010-02-10 14:13:07 +08:00
|
|
|
; TO: ret i64 8
|
|
|
|
; TO: }
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @fa
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2310) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> (2310 * sizeof(double))
|
|
|
|
; SCEV: Classifying expressions for: @fb
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> alignof(double)
|
|
|
|
; SCEV: Classifying expressions for: @fc
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> (2 * sizeof(double))
|
|
|
|
; SCEV: Classifying expressions for: @fd
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 11) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> (11 * sizeof(double))
|
|
|
|
; SCEV: Classifying expressions for: @fe
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 ptrtoint (double* getelementptr ({ double, float, double, double }, { double, float, double, double }* null, i64 0, i32 2) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> offsetof({ double, float, double, double }, 2)
|
|
|
|
; SCEV: Classifying expressions for: @ff
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: %t = bitcast i64 1 to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: --> 1
|
2010-02-02 09:41:39 +08:00
|
|
|
; SCEV: Classifying expressions for: @fg
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 09:41:39 +08:00
|
|
|
; SCEV: --> alignof(double)
|
2010-02-10 14:13:07 +08:00
|
|
|
; SCEV: Classifying expressions for: @fh
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64) to i64
|
2010-02-10 14:13:07 +08:00
|
|
|
; SCEV: --> sizeof(i1*)
|
|
|
|
; SCEV: Classifying expressions for: @fi
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64 ptrtoint (i1** getelementptr ({ i1, i1* }, { i1, i1* }* null, i64 0, i32 1) to i64) to i64
|
2010-02-10 14:13:07 +08:00
|
|
|
; SCEV: --> alignof(i1*)
|
2010-02-02 02:27:38 +08:00
|
|
|
|
|
|
|
define i64 @fa() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 mul (i64 3, i64 mul (i64 ptrtoint ({[7 x double], [7 x double]}* getelementptr ({[7 x double], [7 x double]}, {[7 x double], [7 x double]}* null, i64 11) to i64), i64 5)) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @fb() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint ([13 x double]* getelementptr ({i1, [13 x double]}, {i1, [13 x double]}* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @fc() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (double* getelementptr ({double, double, double, double}, {double, double, double, double}* null, i64 0, i32 2) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @fd() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (double* getelementptr ([13 x double], [13 x double]* null, i64 0, i32 11) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @fe() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (double* getelementptr ({double, float, double, double}, {double, float, double, double}* null, i64 0, i32 2) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @ff() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (<{ i16, i128 }>* getelementptr ({i1, <{ i16, i128 }>}, {i1, <{ i16, i128 }>}* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
2010-02-02 09:41:39 +08:00
|
|
|
define i64 @fg() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint ({double, double}* getelementptr ({i1, {double, double}}, {i1, {double, double}}* null, i64 0, i32 1) to i64) to i64
|
2010-02-02 09:41:39 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
2010-02-10 14:13:07 +08:00
|
|
|
define i64 @fh() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (double** getelementptr (double*, double** null, i32 1) to i64) to i64
|
2010-02-10 14:13:07 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
|
|
|
define i64 @fi() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64 ptrtoint (double** getelementptr ({i1, double*}, {i1, double*}* null, i64 0, i32 1) to i64) to i64
|
2010-02-10 14:13:07 +08:00
|
|
|
ret i64 %t
|
|
|
|
}
|
2010-02-02 02:27:38 +08:00
|
|
|
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64* @fM() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64* getelementptr (i64, i64* null, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64* %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64* @fN() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64* getelementptr ({ i64, i64 }, { i64, i64 }* null, i32 0, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64* %t
|
|
|
|
; PLAIN: }
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i64* @fO() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i64* getelementptr ([2 x i64], [2 x i64]* null, i32 0, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
; PLAIN: ret i64* %t
|
|
|
|
; PLAIN: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64* @fM() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64* inttoptr (i64 8 to i64*)
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64* @fN() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64* inttoptr (i64 8 to i64*)
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i64* @fO() local_unnamed_addr #0 {
|
2015-03-05 02:43:29 +08:00
|
|
|
; OPT: ret i64* inttoptr (i64 8 to i64*)
|
2010-02-02 02:27:38 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64* @fM() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64* @fN() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i64* @fO() local_unnamed_addr #0 {
|
2010-02-02 02:27:38 +08:00
|
|
|
; TO: ret i64* inttoptr (i64 8 to i64*)
|
|
|
|
; TO: }
|
|
|
|
; SCEV: Classifying expressions for: @fM
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64* getelementptr (i64, i64* null, i32 1) to i64*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> 8
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @fN
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64* getelementptr ({ i64, i64 }, { i64, i64 }* null, i32 0, i32 1) to i64*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> 8
|
2010-02-02 02:27:38 +08:00
|
|
|
; SCEV: Classifying expressions for: @fO
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i64* getelementptr ([2 x i64], [2 x i64]* null, i32 0, i32 1) to i64*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> 8
|
2010-02-02 02:27:38 +08:00
|
|
|
|
|
|
|
define i64* @fM() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64* getelementptr (i64, i64* null, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64* %t
|
|
|
|
}
|
|
|
|
define i64* @fN() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64* getelementptr ({ i64, i64 }, { i64, i64 }* null, i32 0, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64* %t
|
|
|
|
}
|
|
|
|
define i64* @fO() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i64* getelementptr ([2 x i64], [2 x i64]* null, i32 0, i32 1) to i64*
|
2010-02-02 02:27:38 +08:00
|
|
|
ret i64* %t
|
2010-01-29 02:08:26 +08:00
|
|
|
}
|
2010-03-11 03:31:51 +08:00
|
|
|
|
2013-02-20 15:21:42 +08:00
|
|
|
; PLAIN: define i32* @fZ() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; PLAIN: %t = bitcast i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32*
|
2010-03-11 03:31:51 +08:00
|
|
|
; PLAIN: ret i32* %t
|
|
|
|
; PLAIN: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; OPT: define i32* @fZ() local_unnamed_addr #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; OPT: ret i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
|
2010-03-11 03:31:51 +08:00
|
|
|
; OPT: }
|
2016-06-15 05:01:22 +08:00
|
|
|
; TO: define i32* @fZ() local_unnamed_addr #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
; TO: ret i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
|
2010-03-11 03:31:51 +08:00
|
|
|
; TO: }
|
|
|
|
; SCEV: Classifying expressions for: @fZ
|
2015-03-14 02:20:45 +08:00
|
|
|
; SCEV: %t = bitcast i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32*
|
2015-03-05 02:43:29 +08:00
|
|
|
; SCEV: --> (12 + @ext)
|
2010-03-11 03:31:51 +08:00
|
|
|
|
|
|
|
define i32* @fZ() nounwind {
|
2015-03-14 02:20:45 +08:00
|
|
|
%t = bitcast i32* getelementptr inbounds (i32, i32* getelementptr inbounds ([3 x { i32, i32 }], [3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32*
|
2010-03-11 03:31:51 +08:00
|
|
|
ret i32* %t
|
|
|
|
}
|
2013-02-20 15:21:42 +08:00
|
|
|
|
2013-02-27 10:26:42 +08:00
|
|
|
; PR15262 - Check GEP folding with casts between address spaces.
|
|
|
|
|
|
|
|
@p0 = global [4 x i8] zeroinitializer, align 1
|
|
|
|
@p12 = addrspace(12) global [4 x i8] zeroinitializer, align 1
|
|
|
|
|
|
|
|
define i8* @different_addrspace() nounwind noinline {
|
|
|
|
; OPT: different_addrspace
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%p = getelementptr inbounds i8, i8* addrspacecast ([4 x i8] addrspace(12)* @p12 to i8*),
|
2013-02-27 10:26:42 +08:00
|
|
|
i32 2
|
|
|
|
ret i8* %p
|
2015-03-14 02:20:45 +08:00
|
|
|
; OPT: ret i8* getelementptr ([4 x i8], [4 x i8]* addrspacecast ([4 x i8] addrspace(12)* @p12 to [4 x i8]*), i64 0, i64 2)
|
2013-02-27 10:26:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i8* @same_addrspace() nounwind noinline {
|
|
|
|
; OPT: same_addrspace
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%p = getelementptr inbounds i8, i8* bitcast ([4 x i8] * @p0 to i8*), i32 2
|
2013-02-27 10:26:42 +08:00
|
|
|
ret i8* %p
|
2015-03-14 02:20:45 +08:00
|
|
|
; OPT: ret i8* getelementptr inbounds ([4 x i8], [4 x i8]* @p0, i64 0, i64 2)
|
2013-02-27 10:26:42 +08:00
|
|
|
}
|
|
|
|
|
2014-07-05 06:05:26 +08:00
|
|
|
@gv1 = internal global i32 1
|
|
|
|
@gv2 = internal global [1 x i32] [ i32 2 ]
|
|
|
|
@gv3 = internal global [1 x i32] [ i32 2 ]
|
|
|
|
|
|
|
|
; Handled by TI-independent constant folder
|
|
|
|
define i1 @gv_gep_vs_gv() {
|
2015-03-14 02:20:45 +08:00
|
|
|
ret i1 icmp eq (i32* getelementptr inbounds ([1 x i32], [1 x i32]* @gv2, i32 0, i32 0), i32* @gv1)
|
2014-07-05 06:05:26 +08:00
|
|
|
}
|
|
|
|
; PLAIN: gv_gep_vs_gv
|
|
|
|
; PLAIN: ret i1 false
|
|
|
|
|
|
|
|
define i1 @gv_gep_vs_gv_gep() {
|
2015-03-14 02:20:45 +08:00
|
|
|
ret i1 icmp eq (i32* getelementptr inbounds ([1 x i32], [1 x i32]* @gv2, i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @gv3, i32 0, i32 0))
|
2014-07-05 06:05:26 +08:00
|
|
|
}
|
|
|
|
; PLAIN: gv_gep_vs_gv_gep
|
|
|
|
; PLAIN: ret i1 false
|
|
|
|
|
2013-02-20 15:21:42 +08:00
|
|
|
; CHECK: attributes #0 = { nounwind }
|