2016-05-02 22:21:55 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2002-05-03 01:01:39 +08:00
|
|
|
; Tests to make sure elimination of casts is working correctly
|
2009-10-12 15:18:14 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2014-02-14 08:49:12 +08:00
|
|
|
target datalayout = "E-p:64:64:64-p1:32:32:32-p2:64:64:64-p3:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64"
|
2002-05-03 01:01:39 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
@inbuf = external global [32832 x i8] ; <[32832 x i8]*> [#uses=1]
|
2004-02-22 13:24:09 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test1(i32 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
|
|
|
; CHECK-NEXT: ret i32 %A
|
|
|
|
;
|
|
|
|
%c1 = bitcast i32 %A to i32 ; <i32> [#uses=1]
|
|
|
|
%c2 = bitcast i32 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %c2
|
2002-08-03 02:48:09 +08:00
|
|
|
}
|
2002-05-03 01:01:39 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i64 @test2(i8 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
|
|
|
; CHECK-NEXT: [[RET:%.*]] = zext i8 %A to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[RET]]
|
|
|
|
;
|
|
|
|
%c1 = zext i8 %A to i16 ; <i16> [#uses=1]
|
|
|
|
%c2 = zext i16 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
%Ret = zext i32 %c2 to i64 ; <i64> [#uses=1]
|
|
|
|
ret i64 %Ret
|
2002-08-03 02:48:09 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
; This function should just use bitwise AND
|
|
|
|
define i64 @test3(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
|
|
|
; CHECK-NEXT: [[C2:%.*]] = and i64 %A, 255
|
|
|
|
; CHECK-NEXT: ret i64 [[C2]]
|
|
|
|
;
|
|
|
|
%c1 = trunc i64 %A to i8 ; <i8> [#uses=1]
|
|
|
|
%c2 = zext i8 %c1 to i64 ; <i64> [#uses=1]
|
|
|
|
ret i64 %c2
|
2002-08-03 02:48:09 +08:00
|
|
|
}
|
2002-08-16 00:13:29 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test4(i32 %A, i32 %B) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 %A, %B
|
|
|
|
; CHECK-NEXT: [[RESULT:%.*]] = zext i1 [[COND]] to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[RESULT]]
|
|
|
|
;
|
|
|
|
%COND = icmp slt i32 %A, %B ; <i1> [#uses=1]
|
|
|
|
; Booleans are unsigned integrals
|
|
|
|
%c = zext i1 %COND to i8 ; <i8> [#uses=1]
|
|
|
|
; for the cast elim purpose
|
|
|
|
%result = zext i8 %c to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %result
|
2002-08-16 00:13:29 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test5(i1 %B) {
|
|
|
|
; This cast should get folded into
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
|
|
|
; CHECK-NEXT: [[RESULT:%.*]] = zext i1 %B to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[RESULT]]
|
|
|
|
;
|
|
|
|
%c = zext i1 %B to i8 ; <i8> [#uses=1]
|
|
|
|
; this cast
|
|
|
|
%result = zext i8 %c to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %result
|
2002-08-16 00:13:29 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test6(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
|
|
|
; CHECK-NEXT: [[C1:%.*]] = trunc i64 %A to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[C1]]
|
|
|
|
;
|
|
|
|
%c1 = trunc i64 %A to i32 ; <i32> [#uses=1]
|
|
|
|
%res = bitcast i32 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %res
|
2002-08-16 00:13:29 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i64 @test7(i1 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
|
|
|
; CHECK-NEXT: [[RES:%.*]] = zext i1 %A to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[RES]]
|
|
|
|
;
|
|
|
|
%c1 = zext i1 %A to i32 ; <i32> [#uses=1]
|
|
|
|
%res = sext i32 %c1 to i64 ; <i64> [#uses=1]
|
|
|
|
ret i64 %res
|
2002-08-16 00:13:29 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i64 @test8(i8 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test8(
|
|
|
|
; CHECK-NEXT: [[C1:%.*]] = sext i8 %A to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[C1]]
|
|
|
|
;
|
|
|
|
%c1 = sext i8 %A to i64 ; <i64> [#uses=1]
|
|
|
|
%res = bitcast i64 %c1 to i64 ; <i64> [#uses=1]
|
|
|
|
ret i64 %res
|
2002-08-16 00:13:29 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test9(i16 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test9(
|
|
|
|
; CHECK-NEXT: ret i16 %A
|
|
|
|
;
|
|
|
|
%c1 = sext i16 %A to i32 ; <i32> [#uses=1]
|
|
|
|
%c2 = trunc i32 %c1 to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %c2
|
2002-09-24 07:39:17 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test10(i16 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test10(
|
|
|
|
; CHECK-NEXT: ret i16 %A
|
|
|
|
;
|
|
|
|
%c1 = sext i16 %A to i32 ; <i32> [#uses=1]
|
|
|
|
%c2 = trunc i32 %c1 to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %c2
|
2002-09-24 07:39:17 +08:00
|
|
|
}
|
2003-06-24 05:48:26 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
declare void @varargs(i32, ...)
|
2003-10-08 06:53:46 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define void @test11(i32* %P) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test11(
|
|
|
|
; CHECK-NEXT: call void (i32, ...) @varargs(i32 5, i32* %P)
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
;
|
|
|
|
%c = bitcast i32* %P to i16* ; <i16*> [#uses=1]
|
|
|
|
call void (i32, ...) @varargs( i32 5, i16* %c )
|
|
|
|
ret void
|
2003-10-08 06:53:46 +08:00
|
|
|
}
|
2003-11-02 13:56:58 +08:00
|
|
|
|
2014-12-05 03:13:45 +08:00
|
|
|
declare i32 @__gxx_personality_v0(...)
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test_invoke_vararg_cast(i32* %a, i32* %b) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test_invoke_vararg_cast(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: invoke void (i32, ...) @varargs(i32 1, i32* %b, i32* %a)
|
|
|
|
; CHECK-NEXT: to label %invoke.cont unwind label %lpad
|
|
|
|
; CHECK: invoke.cont:
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK: lpad:
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = landingpad { i8*, i32
|
|
|
|
;
|
2014-12-05 03:13:45 +08:00
|
|
|
entry:
|
|
|
|
%0 = bitcast i32* %b to i8*
|
|
|
|
%1 = bitcast i32* %a to i64*
|
2015-04-25 03:32:54 +08:00
|
|
|
invoke void (i32, ...) @varargs(i32 1, i8* %0, i64* %1)
|
2016-05-02 22:21:55 +08:00
|
|
|
to label %invoke.cont unwind label %lpad
|
2014-12-05 03:13:45 +08:00
|
|
|
|
|
|
|
invoke.cont: ; preds = %entry
|
|
|
|
ret void
|
|
|
|
|
|
|
|
lpad: ; preds = %entry
|
2015-06-18 04:52:32 +08:00
|
|
|
%2 = landingpad { i8*, i32 }
|
2016-05-02 22:21:55 +08:00
|
|
|
cleanup
|
2014-12-05 03:13:45 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i8* @test13(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test13(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = getelementptr [32832 x i8], [32832 x i8]* @inbuf, i64 0, i64 %A
|
|
|
|
; CHECK-NEXT: ret i8* [[C]]
|
|
|
|
;
|
|
|
|
%c = getelementptr [0 x i8], [0 x i8]* bitcast ([32832 x i8]* @inbuf to [0 x i8]*), i64 0, i64 %A ; <i8*> [#uses=1]
|
|
|
|
ret i8* %c
|
2004-02-22 13:24:09 +08:00
|
|
|
}
|
2004-02-23 15:16:03 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test14(i8 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test14(
|
|
|
|
; CHECK-NEXT: [[X:%.*]] = icmp sgt i8 %A, -1
|
|
|
|
; CHECK-NEXT: ret i1 [[X]]
|
|
|
|
;
|
|
|
|
%c = bitcast i8 %A to i8 ; <i8> [#uses=1]
|
|
|
|
%X = icmp ult i8 %c, -128 ; <i1> [#uses=1]
|
|
|
|
ret i1 %X
|
2004-02-23 15:16:03 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
|
2006-12-23 14:05:41 +08:00
|
|
|
; This just won't occur when there's no difference between ubyte and sbyte
|
|
|
|
;bool %test15(ubyte %A) {
|
|
|
|
; %c = cast ubyte %A to sbyte
|
|
|
|
; %X = setlt sbyte %c, 0 ; setgt %A, 127
|
|
|
|
; ret bool %X
|
|
|
|
;}
|
2004-02-23 15:16:03 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test16(i32* %P) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test16(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = icmp ne i32* %P, null
|
|
|
|
; CHECK-NEXT: ret i1 [[C]]
|
|
|
|
;
|
|
|
|
%c = icmp ne i32* %P, null ; <i1> [#uses=1]
|
|
|
|
ret i1 %c
|
2004-05-25 12:28:43 +08:00
|
|
|
}
|
2004-07-20 08:57:21 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test17(i1 %tmp3) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test17(
|
|
|
|
; CHECK-NEXT: [[T86:%.*]] = zext i1 %tmp3 to i16
|
|
|
|
; CHECK-NEXT: ret i16 [[T86]]
|
|
|
|
;
|
|
|
|
%c = zext i1 %tmp3 to i32 ; <i32> [#uses=1]
|
|
|
|
%t86 = trunc i32 %c to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %t86
|
2004-07-20 08:57:21 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test18(i8 %tmp3) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test18(
|
|
|
|
; CHECK-NEXT: [[T86:%.*]] = sext i8 %tmp3 to i16
|
|
|
|
; CHECK-NEXT: ret i16 [[T86]]
|
|
|
|
;
|
|
|
|
%c = sext i8 %tmp3 to i32 ; <i32> [#uses=1]
|
|
|
|
%t86 = trunc i32 %c to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %t86
|
2004-07-20 08:57:21 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test19(i32 %X) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test19(
|
|
|
|
; CHECK-NEXT: [[Z:%.*]] = icmp slt i32 %X, 12345
|
|
|
|
; CHECK-NEXT: ret i1 [[Z]]
|
|
|
|
;
|
2016-06-05 05:41:25 +08:00
|
|
|
%c = sext i32 %X to i64
|
|
|
|
%Z = icmp slt i64 %c, 12345
|
2016-05-02 22:21:55 +08:00
|
|
|
ret i1 %Z
|
2004-09-29 11:18:20 +08:00
|
|
|
}
|
|
|
|
|
2016-06-05 05:41:25 +08:00
|
|
|
define <2 x i1> @test19vec(<2 x i32> %X) {
|
|
|
|
; CHECK-LABEL: @test19vec(
|
2016-06-05 06:04:05 +08:00
|
|
|
; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i32> %X, <i32 12345, i32 2147483647>
|
2016-06-05 05:41:25 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[Z]]
|
|
|
|
;
|
|
|
|
%c = sext <2 x i32> %X to <2 x i64>
|
|
|
|
%Z = icmp slt <2 x i64> %c, <i64 12345, i64 2147483647>
|
|
|
|
ret <2 x i1> %Z
|
|
|
|
}
|
|
|
|
|
2016-06-05 06:04:05 +08:00
|
|
|
define <3 x i1> @test19vec2(<3 x i1> %X) {
|
|
|
|
; CHECK-LABEL: @test19vec2(
|
2016-06-06 01:49:45 +08:00
|
|
|
; CHECK-NEXT: [[CMPEQ:%.*]] = xor <3 x i1> %X, <i1 true, i1 true, i1 true>
|
2016-06-05 06:04:05 +08:00
|
|
|
; CHECK-NEXT: ret <3 x i1> [[CMPEQ]]
|
|
|
|
;
|
|
|
|
%sext = sext <3 x i1> %X to <3 x i32>
|
|
|
|
%cmpeq = icmp eq <3 x i32> %sext, zeroinitializer
|
|
|
|
ret <3 x i1> %cmpeq
|
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test20(i1 %B) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test20(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%c = zext i1 %B to i32 ; <i32> [#uses=1]
|
|
|
|
%D = icmp slt i32 %c, -1 ; <i1> [#uses=1]
|
|
|
|
;; false
|
|
|
|
ret i1 %D
|
2004-09-29 11:18:20 +08:00
|
|
|
}
|
2005-01-02 00:13:43 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test21(i32 %X) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test21(
|
|
|
|
; CHECK-NEXT: [[C21:%.*]] = and i32 %X, 255
|
|
|
|
; CHECK-NEXT: ret i32 [[C21]]
|
|
|
|
;
|
|
|
|
%c1 = trunc i32 %X to i8 ; <i8> [#uses=1]
|
|
|
|
;; sext -> zext -> and -> nop
|
|
|
|
%c2 = sext i8 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
%RV = and i32 %c2, 255 ; <i32> [#uses=1]
|
|
|
|
ret i32 %RV
|
2005-01-02 00:13:43 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test22(i32 %X) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test22(
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = shl i32 %X, 24
|
|
|
|
; CHECK-NEXT: ret i32 [[SEXT]]
|
|
|
|
;
|
|
|
|
%c1 = trunc i32 %X to i8 ; <i8> [#uses=1]
|
|
|
|
;; sext -> zext -> and -> nop
|
|
|
|
%c2 = sext i8 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
%RV = shl i32 %c2, 24 ; <i32> [#uses=1]
|
|
|
|
ret i32 %RV
|
2005-01-02 00:13:43 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test23(i32 %X) {
|
|
|
|
;; Turn into an AND even though X
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test23(
|
|
|
|
; CHECK-NEXT: [[C2:%.*]] = and i32 %X, 65535
|
|
|
|
; CHECK-NEXT: ret i32 [[C2]]
|
|
|
|
;
|
|
|
|
%c1 = trunc i32 %X to i16 ; <i16> [#uses=1]
|
|
|
|
;; and Z are signed.
|
|
|
|
%c2 = zext i16 %c1 to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %c2
|
2005-01-02 00:13:43 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test24(i1 %C) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test24(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%X = select i1 %C, i32 14, i32 1234 ; <i32> [#uses=1]
|
|
|
|
;; Fold cast into select
|
|
|
|
%c = icmp ne i32 %X, 0 ; <i1> [#uses=1]
|
|
|
|
ret i1 %c
|
2005-01-02 00:13:43 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test26(float %F) {
|
|
|
|
;; no need to cast from float->double.
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test26(
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = fptosi float %F to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[D]]
|
|
|
|
;
|
|
|
|
%c = fpext float %F to double ; <double> [#uses=1]
|
|
|
|
%D = fptosi double %c to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %D
|
2006-01-19 15:39:20 +08:00
|
|
|
}
|
2006-04-13 02:07:41 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define [4 x float]* @test27([9 x [4 x float]]* %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test27(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [9 x [4 x float]], [9 x [4 x float]]* %A, i64 0, i64 0
|
|
|
|
; CHECK-NEXT: ret [4 x float]* [[C]]
|
|
|
|
;
|
|
|
|
%c = bitcast [9 x [4 x float]]* %A to [4 x float]* ; <[4 x float]*> [#uses=1]
|
|
|
|
ret [4 x float]* %c
|
2006-04-13 02:07:41 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define float* @test28([4 x float]* %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test28(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = getelementptr inbounds [4 x float], [4 x float]* %A, i64 0, i64 0
|
|
|
|
; CHECK-NEXT: ret float* [[C]]
|
|
|
|
;
|
|
|
|
%c = bitcast [4 x float]* %A to float* ; <float*> [#uses=1]
|
|
|
|
ret float* %c
|
2006-04-13 02:07:41 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test29(i32 %c1, i32 %c2) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test29(
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = or i32 %c2, %c1
|
|
|
|
; CHECK-NEXT: [[TMP10:%.*]] = and i32 [[TMP2]], 255
|
|
|
|
; CHECK-NEXT: ret i32 [[TMP10]]
|
|
|
|
;
|
|
|
|
%tmp1 = trunc i32 %c1 to i8 ; <i8> [#uses=1]
|
|
|
|
%tmp4.mask = trunc i32 %c2 to i8 ; <i8> [#uses=1]
|
|
|
|
%tmp = or i8 %tmp4.mask, %tmp1 ; <i8> [#uses=1]
|
|
|
|
%tmp10 = zext i8 %tmp to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp10
|
2006-05-05 14:38:40 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test30(i32 %c1) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test30(
|
|
|
|
; CHECK-NEXT: [[C3:%.*]] = and i32 %c1, 255
|
|
|
|
; CHECK-NEXT: [[C4:%.*]] = xor i32 [[C3]], 1
|
|
|
|
; CHECK-NEXT: ret i32 [[C4]]
|
|
|
|
;
|
|
|
|
%c2 = trunc i32 %c1 to i8 ; <i8> [#uses=1]
|
|
|
|
%c3 = xor i8 %c2, 1 ; <i8> [#uses=1]
|
|
|
|
%c4 = zext i8 %c3 to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %c4
|
2006-05-13 10:00:07 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i1 @test31(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test31(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and i64 %A, 42
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = icmp eq i64 [[C]], 10
|
|
|
|
; CHECK-NEXT: ret i1 [[D]]
|
|
|
|
;
|
2016-08-15 06:30:07 +08:00
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = and i32 %B, 42
|
|
|
|
%D = icmp eq i32 %C, 10
|
2016-05-02 22:21:55 +08:00
|
|
|
ret i1 %D
|
2006-09-18 13:25:10 +08:00
|
|
|
}
|
2006-05-13 10:00:07 +08:00
|
|
|
|
2016-08-19 04:28:54 +08:00
|
|
|
; FIXME: Vectors should fold too...or not?
|
2016-08-15 06:30:07 +08:00
|
|
|
; Does this depend on the whether the source/dest types of the trunc are legal in the data layout?
|
|
|
|
define <2 x i1> @test31vec(<2 x i64> %A) {
|
|
|
|
; CHECK-LABEL: @test31vec(
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = trunc <2 x i64> %A to <2 x i32>
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and <2 x i32> [[B]], <i32 42, i32 42>
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = icmp eq <2 x i32> [[C]], <i32 10, i32 10>
|
|
|
|
; CHECK-NEXT: ret <2 x i1> [[D]]
|
|
|
|
;
|
|
|
|
%B = trunc <2 x i64> %A to <2 x i32>
|
|
|
|
%C = and <2 x i32> %B, <i32 42, i32 42>
|
|
|
|
%D = icmp eq <2 x i32> %C, <i32 10, i32 10>
|
|
|
|
ret <2 x i1> %D
|
|
|
|
}
|
|
|
|
|
2016-09-01 22:20:43 +08:00
|
|
|
; Verify that the 'and' was narrowed, the zext was eliminated, and the compare was narrowed
|
|
|
|
; even for vectors. Earlier folds should ensure that the icmp(and(zext)) pattern never occurs.
|
|
|
|
|
|
|
|
define <2 x i1> @test32vec(<2 x i8> %A) {
|
|
|
|
; CHECK-LABEL: @test32vec(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i8> %A, <i8 42, i8 42>
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = icmp eq <2 x i8> [[TMP1]], <i8 10, i8 10>
|
|
|
|
; CHECK-NEXT: ret <2 x i1> [[D]]
|
|
|
|
;
|
|
|
|
%B = zext <2 x i8> %A to <2 x i16>
|
|
|
|
%C = and <2 x i16> %B, <i16 42, i16 42>
|
|
|
|
%D = icmp eq <2 x i16> %C, <i16 10, i16 10>
|
|
|
|
ret <2 x i1> %D
|
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i32 @test33(i32 %c1) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test33(
|
|
|
|
; CHECK-NEXT: ret i32 %c1
|
|
|
|
;
|
|
|
|
%x = bitcast i32 %c1 to float ; <float> [#uses=1]
|
|
|
|
%y = bitcast float %x to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %y
|
2006-11-27 09:05:10 +08:00
|
|
|
}
|
2006-11-29 15:03:00 +08:00
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test34(i16 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test34(
|
|
|
|
; CHECK-NEXT: [[TMP21:%.*]] = lshr i16 %a, 8
|
|
|
|
; CHECK-NEXT: ret i16 [[TMP21]]
|
|
|
|
;
|
|
|
|
%c1 = zext i16 %a to i32 ; <i32> [#uses=1]
|
|
|
|
%tmp21 = lshr i32 %c1, 8 ; <i32> [#uses=1]
|
|
|
|
%c2 = trunc i32 %tmp21 to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %c2
|
2006-11-29 15:03:00 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 12:26:08 +08:00
|
|
|
define i16 @test35(i16 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test35(
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = lshr i16 %a, 8
|
|
|
|
; CHECK-NEXT: ret i16 [[TMP2]]
|
|
|
|
;
|
|
|
|
%c1 = bitcast i16 %a to i16 ; <i16> [#uses=1]
|
|
|
|
%tmp2 = lshr i16 %c1, 8 ; <i16> [#uses=1]
|
|
|
|
%c2 = bitcast i16 %tmp2 to i16 ; <i16> [#uses=1]
|
|
|
|
ret i16 %c2
|
2006-11-29 15:17:32 +08:00
|
|
|
}
|
|
|
|
|
Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
%.lobit.i = lshr i32 %25, 31 ; <i32> [#uses=1]
%tmp.i = trunc i32 %.lobit.i to i8 ; <i8> [#uses=1]
%toBool = icmp eq i8 %tmp.i, 0 ; <i1> [#uses=1]
br i1 %toBool, label %bb3, label %bb4
which compiled to:
call L_memcmp$stub
shrl $31, %eax
testb %al, %al
jne LBB1_11 ##
with this change, we compile it to:
call L_memcmp$stub
testl %eax, %eax
js LBB1_11
This triggers all the time in common code, with patters like this:
%169 = and i32 %ply, 1 ; <i32> [#uses=1]
%170 = trunc i32 %169 to i8 ; <i8> [#uses=1]
%toBool = icmp ne i8 %170, 0 ; <i1> [#uses=1]
%7 = lshr i32 %6, 24 ; <i32> [#uses=1]
%9 = trunc i32 %7 to i8 ; <i8> [#uses=1]
%10 = icmp ne i8 %9, 0 ; <i1> [#uses=1]
etc
llvm-svn: 61985
2009-01-09 15:47:06 +08:00
|
|
|
; rdar://6480391
|
|
|
|
define i1 @test36(i32 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test36(
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = icmp sgt i32 %a, -1
|
|
|
|
; CHECK-NEXT: ret i1 [[D]]
|
|
|
|
;
|
|
|
|
%b = lshr i32 %a, 31
|
|
|
|
%c = trunc i32 %b to i8
|
|
|
|
%d = icmp eq i8 %c, 0
|
|
|
|
ret i1 %d
|
Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
%.lobit.i = lshr i32 %25, 31 ; <i32> [#uses=1]
%tmp.i = trunc i32 %.lobit.i to i8 ; <i8> [#uses=1]
%toBool = icmp eq i8 %tmp.i, 0 ; <i1> [#uses=1]
br i1 %toBool, label %bb3, label %bb4
which compiled to:
call L_memcmp$stub
shrl $31, %eax
testb %al, %al
jne LBB1_11 ##
with this change, we compile it to:
call L_memcmp$stub
testl %eax, %eax
js LBB1_11
This triggers all the time in common code, with patters like this:
%169 = and i32 %ply, 1 ; <i32> [#uses=1]
%170 = trunc i32 %169 to i8 ; <i8> [#uses=1]
%toBool = icmp ne i8 %170, 0 ; <i1> [#uses=1]
%7 = lshr i32 %6, 24 ; <i32> [#uses=1]
%9 = trunc i32 %7 to i8 ; <i8> [#uses=1]
%10 = icmp ne i8 %9, 0 ; <i1> [#uses=1]
etc
llvm-svn: 61985
2009-01-09 15:47:06 +08:00
|
|
|
}
|
|
|
|
|
2016-08-10 00:05:57 +08:00
|
|
|
define <2 x i1> @test36vec(<2 x i32> %a) {
|
|
|
|
; CHECK-LABEL: @test36vec(
|
2016-08-25 06:22:06 +08:00
|
|
|
; CHECK-NEXT: [[D:%.*]] = icmp sgt <2 x i32> %a, <i32 -1, i32 -1>
|
2016-08-10 00:05:57 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[D]]
|
|
|
|
;
|
|
|
|
%b = lshr <2 x i32> %a, <i32 31, i32 31>
|
|
|
|
%c = trunc <2 x i32> %b to <2 x i8>
|
|
|
|
%d = icmp eq <2 x i8> %c, zeroinitializer
|
|
|
|
ret <2 x i1> %d
|
|
|
|
}
|
|
|
|
|
Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
%.lobit.i = lshr i32 %25, 31 ; <i32> [#uses=1]
%tmp.i = trunc i32 %.lobit.i to i8 ; <i8> [#uses=1]
%toBool = icmp eq i8 %tmp.i, 0 ; <i1> [#uses=1]
br i1 %toBool, label %bb3, label %bb4
which compiled to:
call L_memcmp$stub
shrl $31, %eax
testb %al, %al
jne LBB1_11 ##
with this change, we compile it to:
call L_memcmp$stub
testl %eax, %eax
js LBB1_11
This triggers all the time in common code, with patters like this:
%169 = and i32 %ply, 1 ; <i32> [#uses=1]
%170 = trunc i32 %169 to i8 ; <i8> [#uses=1]
%toBool = icmp ne i8 %170, 0 ; <i1> [#uses=1]
%7 = lshr i32 %6, 24 ; <i32> [#uses=1]
%9 = trunc i32 %7 to i8 ; <i8> [#uses=1]
%10 = icmp ne i8 %9, 0 ; <i1> [#uses=1]
etc
llvm-svn: 61985
2009-01-09 15:47:06 +08:00
|
|
|
define i1 @test37(i32 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test37(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%b = lshr i32 %a, 31
|
|
|
|
%c = or i32 %b, 512
|
|
|
|
%d = trunc i32 %c to i8
|
|
|
|
%e = icmp eq i8 %d, 11
|
|
|
|
ret i1 %e
|
Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
%.lobit.i = lshr i32 %25, 31 ; <i32> [#uses=1]
%tmp.i = trunc i32 %.lobit.i to i8 ; <i8> [#uses=1]
%toBool = icmp eq i8 %tmp.i, 0 ; <i1> [#uses=1]
br i1 %toBool, label %bb3, label %bb4
which compiled to:
call L_memcmp$stub
shrl $31, %eax
testb %al, %al
jne LBB1_11 ##
with this change, we compile it to:
call L_memcmp$stub
testl %eax, %eax
js LBB1_11
This triggers all the time in common code, with patters like this:
%169 = and i32 %ply, 1 ; <i32> [#uses=1]
%170 = trunc i32 %169 to i8 ; <i8> [#uses=1]
%toBool = icmp ne i8 %170, 0 ; <i1> [#uses=1]
%7 = lshr i32 %6, 24 ; <i32> [#uses=1]
%9 = trunc i32 %7 to i8 ; <i8> [#uses=1]
%10 = icmp ne i8 %9, 0 ; <i1> [#uses=1]
etc
llvm-svn: 61985
2009-01-09 15:47:06 +08:00
|
|
|
}
|
|
|
|
|
2009-01-16 10:11:43 +08:00
|
|
|
define i64 @test38(i32 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test38(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 %a, -2
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP2]]
|
|
|
|
;
|
|
|
|
%1 = icmp eq i32 %a, -2
|
|
|
|
%2 = zext i1 %1 to i8
|
|
|
|
%3 = xor i8 %2, 1
|
|
|
|
%4 = zext i8 %3 to i64
|
|
|
|
ret i64 %4
|
2009-01-16 10:11:43 +08:00
|
|
|
}
|
2010-01-06 05:48:13 +08:00
|
|
|
|
|
|
|
define i16 @test39(i16 %a) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test39(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[TMP_UPGRD_32:%.*]] = call i16 @llvm.bswap.i16(i16 %a)
|
|
|
|
; CHECK-NEXT: ret i16 [[TMP_UPGRD_32]]
|
|
|
|
;
|
|
|
|
%tmp = zext i16 %a to i32
|
|
|
|
%tmp21 = lshr i32 %tmp, 8
|
|
|
|
%tmp5 = shl i32 %tmp, 8
|
|
|
|
%tmp.upgrd.32 = or i32 %tmp21, %tmp5
|
|
|
|
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16
|
|
|
|
ret i16 %tmp.upgrd.3
|
2010-01-06 05:48:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @test40(i16 %a) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test40(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[TMP21:%.*]] = lshr i16 %a, 9
|
|
|
|
; CHECK-NEXT: [[TMP5:%.*]] = shl i16 %a, 8
|
|
|
|
; CHECK-NEXT: [[TMP_UPGRD_32:%.*]] = or i16 [[TMP21]], [[TMP5]]
|
|
|
|
; CHECK-NEXT: ret i16 [[TMP_UPGRD_32]]
|
|
|
|
;
|
|
|
|
%tmp = zext i16 %a to i32
|
|
|
|
%tmp21 = lshr i32 %tmp, 9
|
|
|
|
%tmp5 = shl i32 %tmp, 8
|
|
|
|
%tmp.upgrd.32 = or i32 %tmp21, %tmp5
|
|
|
|
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16
|
|
|
|
ret i16 %tmp.upgrd.3
|
2010-01-06 05:48:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; PR1263
|
|
|
|
define i32* @test41(i32* %tmp1) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test41(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: ret i32* %tmp1
|
|
|
|
;
|
|
|
|
%tmp64 = bitcast i32* %tmp1 to { i32 }*
|
|
|
|
%tmp65 = getelementptr { i32 }, { i32 }* %tmp64, i32 0, i32 0
|
|
|
|
ret i32* %tmp65
|
2010-01-06 05:48:13 +08:00
|
|
|
}
|
|
|
|
|
2014-08-13 03:46:13 +08:00
|
|
|
define i32 addrspace(1)* @test41_addrspacecast_smaller(i32* %tmp1) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test41_addrspacecast_smaller(
|
|
|
|
; CHECK-NEXT: [[TMP65:%.*]] = addrspacecast i32* %tmp1 to i32 addrspace(1)*
|
|
|
|
; CHECK-NEXT: ret i32 addrspace(1)* [[TMP65]]
|
|
|
|
;
|
2014-08-13 03:46:13 +08:00
|
|
|
%tmp64 = addrspacecast i32* %tmp1 to { i32 } addrspace(1)*
|
[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
|
|
|
%tmp65 = getelementptr { i32 }, { i32 } addrspace(1)* %tmp64, i32 0, i32 0
|
2014-08-13 03:46:13 +08:00
|
|
|
ret i32 addrspace(1)* %tmp65
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @test41_addrspacecast_larger(i32 addrspace(1)* %tmp1) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test41_addrspacecast_larger(
|
|
|
|
; CHECK-NEXT: [[TMP65:%.*]] = addrspacecast i32 addrspace(1)* %tmp1 to i32*
|
|
|
|
; CHECK-NEXT: ret i32* [[TMP65]]
|
|
|
|
;
|
2014-08-13 03:46:13 +08:00
|
|
|
%tmp64 = addrspacecast i32 addrspace(1)* %tmp1 to { i32 }*
|
[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
|
|
|
%tmp65 = getelementptr { i32 }, { i32 }* %tmp64, i32 0, i32 0
|
2014-08-13 03:46:13 +08:00
|
|
|
ret i32* %tmp65
|
|
|
|
}
|
|
|
|
|
2010-01-06 05:54:09 +08:00
|
|
|
define i32 @test42(i32 %X) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test42(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[Z:%.*]] = and i32 %X, 255
|
|
|
|
; CHECK-NEXT: ret i32 [[Z]]
|
|
|
|
;
|
|
|
|
%Y = trunc i32 %X to i8 ; <i8> [#uses=1]
|
|
|
|
%Z = zext i8 %Y to i32 ; <i32> [#uses=1]
|
|
|
|
ret i32 %Z
|
2010-01-06 05:54:09 +08:00
|
|
|
}
|
2010-01-06 05:48:13 +08:00
|
|
|
|
2010-01-06 09:56:21 +08:00
|
|
|
; rdar://6598839
|
|
|
|
define zeroext i64 @test43(i8 zeroext %on_off) nounwind readonly {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test43(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = zext i8 %on_off to i64
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = add nsw i64 [[A]], -1
|
|
|
|
; CHECK-NEXT: ret i64 [[B]]
|
|
|
|
;
|
|
|
|
%A = zext i8 %on_off to i32
|
|
|
|
%B = add i32 %A, -1
|
|
|
|
%C = sext i32 %B to i64
|
|
|
|
ret i64 %C ;; Should be (add (zext i8 -> i64), -1)
|
2010-01-06 09:56:21 +08:00
|
|
|
}
|
2010-01-08 07:41:00 +08:00
|
|
|
|
|
|
|
define i64 @test44(i8 %T) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test44(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = zext i8 %T to i64
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = or i64 [[A]], 1234
|
|
|
|
; CHECK-NEXT: ret i64 [[B]]
|
|
|
|
;
|
|
|
|
%A = zext i8 %T to i16
|
|
|
|
%B = or i16 %A, 1234
|
|
|
|
%C = zext i16 %B to i64
|
|
|
|
ret i64 %C
|
2010-01-08 07:41:00 +08:00
|
|
|
}
|
2010-01-10 10:22:12 +08:00
|
|
|
|
|
|
|
define i64 @test45(i8 %A, i64 %Q) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test45(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[B:%.*]] = sext i8 %A to i64
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = or i64 [[B]], %Q
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = and i64 [[C]], 4294967295
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
|
|
|
%D = trunc i64 %Q to i32 ;; should be removed
|
|
|
|
%B = sext i8 %A to i32
|
|
|
|
%C = or i32 %B, %D
|
|
|
|
%E = zext i32 %C to i64
|
|
|
|
ret i64 %E
|
2010-01-10 10:22:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define i64 @test46(i64 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test46(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[C:%.*]] = shl i64 %A, 8
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = and i64 [[C]], 10752
|
|
|
|
; CHECK-NEXT: ret i64 [[D]]
|
|
|
|
;
|
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = and i32 %B, 42
|
|
|
|
%D = shl i32 %C, 8
|
|
|
|
%E = zext i32 %D to i64
|
|
|
|
ret i64 %E
|
2010-01-10 10:22:12 +08:00
|
|
|
}
|
|
|
|
|
2010-01-10 10:39:31 +08:00
|
|
|
define i64 @test47(i8 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test47(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[B:%.*]] = sext i8 %A to i64
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and i64 [[B]], 4294967253
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = or i64 [[C]], 42
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
|
|
|
%B = sext i8 %A to i32
|
|
|
|
%C = or i32 %B, 42
|
|
|
|
%E = zext i32 %C to i64
|
|
|
|
ret i64 %E
|
2010-01-10 10:39:31 +08:00
|
|
|
}
|
|
|
|
|
2016-05-02 22:21:55 +08:00
|
|
|
define i64 @test48(i8 %A1, i8 %a2) {
|
|
|
|
; CHECK-LABEL: @test48(
|
|
|
|
; CHECK-NEXT: [[Z2:%.*]] = zext i8 %A1 to i32
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = shl nuw nsw i32 [[Z2]], 8
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i32 [[C]], [[Z2]]
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = zext i32 [[D]] to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
|
|
|
%Z1 = zext i8 %a2 to i32
|
|
|
|
%Z2 = zext i8 %A1 to i32
|
|
|
|
%C = shl i32 %Z2, 8
|
|
|
|
%D = or i32 %C, %Z2
|
2010-01-10 10:39:31 +08:00
|
|
|
%E = zext i32 %D to i64
|
|
|
|
ret i64 %E
|
|
|
|
}
|
2010-01-10 10:22:12 +08:00
|
|
|
|
2010-01-10 15:40:50 +08:00
|
|
|
define i64 @test49(i64 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test49(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[C:%.*]] = shl i64 %A, 32
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = ashr exact i64 [[C]], 32
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i64 [[SEXT]], 1
|
|
|
|
; CHECK-NEXT: ret i64 [[D]]
|
|
|
|
;
|
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = or i32 %B, 1
|
|
|
|
%D = sext i32 %C to i64
|
|
|
|
ret i64 %D
|
2010-01-10 15:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test50(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test50(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = lshr i64 %A, 2
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = shl i64 [[A]], 32
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = add i64 [[D]], -4294967296
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = ashr exact i64 [[SEXT]], 32
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
2010-01-10 15:40:50 +08:00
|
|
|
%a = lshr i64 %A, 2
|
|
|
|
%B = trunc i64 %a to i32
|
|
|
|
%D = add i32 %B, -1
|
|
|
|
%E = sext i32 %D to i64
|
|
|
|
ret i64 %E
|
Reapply r155136 after fixing PR12599.
Original commit message:
Defer some shl transforms to DAGCombine.
The shl instruction is used to represent multiplication by a constant
power of two as well as bitwise left shifts. Some InstCombine
transformations would turn an shl instruction into a bit mask operation,
making it difficult for later analysis passes to recognize the
constsnt multiplication.
Disable those shl transformations, deferring them to DAGCombine time.
An 'shl X, C' instruction is now treated mostly the same was as 'mul X, C'.
These transformations are deferred:
(X >>? C) << C --> X & (-1 << C) (When X >> C has multiple uses)
(X >>? C1) << C2 --> X << (C2-C1) & (-1 << C2) (When C2 > C1)
(X >>? C1) << C2 --> X >>? (C1-C2) & (-1 << C2) (When C1 > C2)
The corresponding exact transformations are preserved, just like
div-exact + mul:
(X >>?,exact C) << C --> X
(X >>?,exact C1) << C2 --> X << (C2-C1)
(X >>?,exact C1) << C2 --> X >>?,exact (C1-C2)
The disabled transformations could also prevent the instruction selector
from recognizing rotate patterns in hash functions and cryptographic
primitives. I have a test case for that, but it is too fragile.
llvm-svn: 155362
2012-04-24 01:39:52 +08:00
|
|
|
; lshr+shl will be handled by DAGCombine.
|
2010-01-10 15:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test51(i64 %A, i1 %cond) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test51(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and i64 %A, 4294967294
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i64 %A, 1
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = select i1 %cond, i64 [[C]], i64 [[D]]
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[E]], 32
|
|
|
|
; CHECK-NEXT: [[F:%.*]] = ashr exact i64 [[SEXT]], 32
|
|
|
|
; CHECK-NEXT: ret i64 [[F]]
|
|
|
|
;
|
2010-01-10 15:40:50 +08:00
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = and i32 %B, -2
|
|
|
|
%D = or i32 %B, 1
|
|
|
|
%E = select i1 %cond, i32 %C, i32 %D
|
|
|
|
%F = sext i32 %E to i64
|
|
|
|
ret i64 %F
|
|
|
|
}
|
|
|
|
|
2010-01-11 04:25:54 +08:00
|
|
|
define i32 @test52(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test52(
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = trunc i64 %A to i32
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and i32 [[B]], 7224
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i32 [[C]], 32962
|
|
|
|
; CHECK-NEXT: ret i32 [[D]]
|
|
|
|
;
|
2010-01-11 04:25:54 +08:00
|
|
|
%B = trunc i64 %A to i16
|
|
|
|
%C = or i16 %B, -32574
|
|
|
|
%D = and i16 %C, -25350
|
|
|
|
%E = zext i16 %D to i32
|
|
|
|
ret i32 %E
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test53(i32 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test53(
|
2016-07-21 08:24:18 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %A, 7224
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = or i32 [[TMP1]], 32962
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = zext i32 [[TMP2]] to i64
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: ret i64 [[D]]
|
|
|
|
;
|
2010-01-11 04:25:54 +08:00
|
|
|
%B = trunc i32 %A to i16
|
|
|
|
%C = or i16 %B, -32574
|
|
|
|
%D = and i16 %C, -25350
|
|
|
|
%E = zext i16 %D to i64
|
|
|
|
ret i64 %E
|
|
|
|
}
|
2010-01-11 04:30:41 +08:00
|
|
|
|
|
|
|
define i32 @test54(i64 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test54(
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = trunc i64 %A to i32
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = and i32 [[B]], 7224
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i32 [[C]], -32574
|
|
|
|
; CHECK-NEXT: ret i32 [[D]]
|
|
|
|
;
|
2010-01-11 04:30:41 +08:00
|
|
|
%B = trunc i64 %A to i16
|
|
|
|
%C = or i16 %B, -32574
|
|
|
|
%D = and i16 %C, -25350
|
|
|
|
%E = sext i16 %D to i32
|
|
|
|
ret i32 %E
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test55(i32 %A) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test55(
|
2016-07-21 08:24:18 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %A, 7224
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = zext i32 [[TMP1]] to i64
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[D:%.*]] = or i64 [[C]], -32574
|
|
|
|
; CHECK-NEXT: ret i64 [[D]]
|
|
|
|
;
|
2010-01-11 04:30:41 +08:00
|
|
|
%B = trunc i32 %A to i16
|
|
|
|
%C = or i16 %B, -32574
|
|
|
|
%D = and i16 %C, -25350
|
|
|
|
%E = sext i16 %D to i64
|
|
|
|
ret i64 %E
|
2010-01-11 11:32:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test56(i16 %A) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test56(
|
|
|
|
; CHECK-NEXT: [[TMP353:%.*]] = sext i16 %A to i64
|
|
|
|
; CHECK-NEXT: [[TMP354:%.*]] = lshr i64 [[TMP353]], 5
|
|
|
|
; CHECK-NEXT: [[TMP355:%.*]] = and i64 [[TMP354]], 134217727
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP355]]
|
|
|
|
;
|
2010-01-11 11:32:00 +08:00
|
|
|
%tmp353 = sext i16 %A to i32
|
|
|
|
%tmp354 = lshr i32 %tmp353, 5
|
|
|
|
%tmp355 = zext i32 %tmp354 to i64
|
|
|
|
ret i64 %tmp355
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test57(i64 %A) nounwind {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test57(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[C:%.*]] = lshr i64 %A, 8
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = and i64 [[C]], 16777215
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = lshr i32 %B, 8
|
|
|
|
%E = zext i32 %C to i64
|
|
|
|
ret i64 %E
|
2010-01-11 11:32:00 +08:00
|
|
|
}
|
Extend CanEvaluateZExtd to handle and/or/xor more aggressively in the
BitsToClear case. This allows it to promote expressions which have an
and/or/xor after the lshr, promoting cases like test2 (from PR4216)
and test3 (random extample extracted from a spec benchmark).
clang now compiles the code in PR4216 into:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
orl $32768, %edi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
instead of:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
shrl $8, %edi
orl $128, %edi
shlq $8, %rdi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
which is still not great, but is progress.
llvm-svn: 93145
2010-01-11 12:05:13 +08:00
|
|
|
|
|
|
|
define i64 @test58(i64 %A) nounwind {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test58(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[C:%.*]] = lshr i64 %A, 8
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = and i64 [[C]], 16777087
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = or i64 [[D]], 128
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = lshr i32 %B, 8
|
|
|
|
%D = or i32 %C, 128
|
|
|
|
%E = zext i32 %D to i64
|
|
|
|
ret i64 %E
|
|
|
|
|
Extend CanEvaluateZExtd to handle and/or/xor more aggressively in the
BitsToClear case. This allows it to promote expressions which have an
and/or/xor after the lshr, promoting cases like test2 (from PR4216)
and test3 (random extample extracted from a spec benchmark).
clang now compiles the code in PR4216 into:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
orl $32768, %edi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
instead of:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
shrl $8, %edi
orl $128, %edi
shlq $8, %rdi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
which is still not great, but is progress.
llvm-svn: 93145
2010-01-11 12:05:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test59(i8 %A, i8 %B) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test59(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = zext i8 %A to i64
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = shl nuw nsw i64 [[C]], 4
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = and i64 [[D]], 48
|
|
|
|
; CHECK-NEXT: [[F:%.*]] = zext i8 %B to i64
|
|
|
|
; CHECK-NEXT: [[G:%.*]] = lshr i64 [[F]], 4
|
|
|
|
; CHECK-NEXT: [[H:%.*]] = or i64 [[G]], [[E]]
|
|
|
|
; CHECK-NEXT: ret i64 [[H]]
|
|
|
|
;
|
Extend CanEvaluateZExtd to handle and/or/xor more aggressively in the
BitsToClear case. This allows it to promote expressions which have an
and/or/xor after the lshr, promoting cases like test2 (from PR4216)
and test3 (random extample extracted from a spec benchmark).
clang now compiles the code in PR4216 into:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
orl $32768, %edi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
instead of:
_test_bitfield: ## @test_bitfield
movl %edi, %eax
orl $194, %eax
movl $4294902010, %ecx
andq %rax, %rcx
shrl $8, %edi
orl $128, %edi
shlq $8, %rdi
andq $39936, %rdi
movq %rdi, %rax
orq %rcx, %rax
ret
which is still not great, but is progress.
llvm-svn: 93145
2010-01-11 12:05:13 +08:00
|
|
|
%C = zext i8 %A to i32
|
|
|
|
%D = shl i32 %C, 4
|
|
|
|
%E = and i32 %D, 48
|
|
|
|
%F = zext i8 %B to i32
|
|
|
|
%G = lshr i32 %F, 4
|
|
|
|
%H = or i32 %G, %E
|
|
|
|
%I = zext i32 %H to i64
|
|
|
|
ret i64 %I
|
|
|
|
}
|
2010-05-09 05:50:26 +08:00
|
|
|
|
|
|
|
define <3 x i32> @test60(<4 x i32> %call4) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test60(
|
|
|
|
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x i32> %call4, <4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2>
|
|
|
|
; CHECK-NEXT: ret <3 x i32> [[TMP10]]
|
|
|
|
;
|
2010-05-09 05:50:26 +08:00
|
|
|
%tmp11 = bitcast <4 x i32> %call4 to i128
|
|
|
|
%tmp9 = trunc i128 %tmp11 to i96
|
|
|
|
%tmp10 = bitcast i96 %tmp9 to <3 x i32>
|
|
|
|
ret <3 x i32> %tmp10
|
2016-05-02 22:21:55 +08:00
|
|
|
|
2010-05-09 05:50:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @test61(<3 x i32> %call4) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test61(
|
|
|
|
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <3 x i32> %call4, <3 x i32> <i32 0, i32 undef, i32 undef>, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
|
|
|
; CHECK-NEXT: ret <4 x i32> [[TMP10]]
|
|
|
|
;
|
2010-05-09 05:50:26 +08:00
|
|
|
%tmp11 = bitcast <3 x i32> %call4 to i96
|
|
|
|
%tmp9 = zext i96 %tmp11 to i128
|
|
|
|
%tmp10 = bitcast i128 %tmp9 to <4 x i32>
|
|
|
|
ret <4 x i32> %tmp10
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @test62(<3 x float> %call4) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test62(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = bitcast <3 x float> %call4 to <3 x i32>
|
|
|
|
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <3 x i32> [[TMP1]], <3 x i32> <i32 0, i32 undef, i32 undef>, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
|
|
|
; CHECK-NEXT: ret <4 x i32> [[TMP10]]
|
|
|
|
;
|
2010-05-09 05:50:26 +08:00
|
|
|
%tmp11 = bitcast <3 x float> %call4 to i96
|
|
|
|
%tmp9 = zext i96 %tmp11 to i128
|
|
|
|
%tmp10 = bitcast i128 %tmp9 to <4 x i32>
|
|
|
|
ret <4 x i32> %tmp10
|
|
|
|
}
|
|
|
|
|
2010-07-12 09:19:22 +08:00
|
|
|
; PR7311 - Don't create invalid IR on scalar->vector cast.
|
|
|
|
define <2 x float> @test63(i64 %tmp8) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test63(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = bitcast i64 %tmp8 to <2 x i32>
|
|
|
|
; CHECK-NEXT: [[VCVT_I:%.*]] = uitofp <2 x i32> [[A]] to <2 x float>
|
|
|
|
; CHECK-NEXT: ret <2 x float> [[VCVT_I]]
|
|
|
|
;
|
2010-07-12 09:19:22 +08:00
|
|
|
entry:
|
2016-05-02 22:21:55 +08:00
|
|
|
%a = bitcast i64 %tmp8 to <2 x i32>
|
|
|
|
%vcvt.i = uitofp <2 x i32> %a to <2 x float>
|
2010-07-12 09:19:22 +08:00
|
|
|
ret <2 x float> %vcvt.i
|
|
|
|
}
|
|
|
|
|
2011-08-28 19:51:08 +08:00
|
|
|
define <4 x float> @test64(<4 x float> %c) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test64(
|
|
|
|
; CHECK-NEXT: ret <4 x float> %c
|
|
|
|
;
|
2011-08-28 19:51:08 +08:00
|
|
|
%t0 = bitcast <4 x float> %c to <4 x i32>
|
2011-08-30 03:58:36 +08:00
|
|
|
%t1 = bitcast <4 x i32> %t0 to <4 x float>
|
|
|
|
ret <4 x float> %t1
|
2011-08-28 19:51:08 +08:00
|
|
|
}
|
|
|
|
|
2011-08-30 03:58:36 +08:00
|
|
|
define <4 x float> @test65(<4 x float> %c) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test65(
|
|
|
|
; CHECK-NEXT: ret <4 x float> %c
|
|
|
|
;
|
2011-08-30 03:58:36 +08:00
|
|
|
%t0 = bitcast <4 x float> %c to <2 x double>
|
|
|
|
%t1 = bitcast <2 x double> %t0 to <4 x float>
|
|
|
|
ret <4 x float> %t1
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x float> @test66(<2 x float> %c) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test66(
|
|
|
|
; CHECK-NEXT: ret <2 x float> %c
|
|
|
|
;
|
2011-08-30 03:58:36 +08:00
|
|
|
%t0 = bitcast <2 x float> %c to double
|
|
|
|
%t1 = bitcast double %t0 to <2 x float>
|
|
|
|
ret <2 x float> %t1
|
|
|
|
}
|
|
|
|
|
2011-08-28 19:51:08 +08:00
|
|
|
define float @test2c() {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2c(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: ret float -1.000000e+00
|
|
|
|
;
|
|
|
|
ret float extractelement (<2 x float> bitcast (double bitcast (<2 x float> <float -1.000000e+00, float -1.000000e+00> to double) to <2 x float>), i32 0)
|
2011-08-28 19:51:08 +08:00
|
|
|
}
|
2011-08-30 03:58:36 +08:00
|
|
|
|
|
|
|
define i64 @test_mmx(<2 x i32> %c) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test_mmx(
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = bitcast <2 x i32> %c to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[C]]
|
|
|
|
;
|
2011-08-30 03:58:36 +08:00
|
|
|
%A = bitcast <2 x i32> %c to x86_mmx
|
|
|
|
%B = bitcast x86_mmx %A to <2 x i32>
|
|
|
|
%C = bitcast <2 x i32> %B to i64
|
|
|
|
ret i64 %C
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test_mmx_const(<2 x i32> %c) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test_mmx_const(
|
|
|
|
; CHECK-NEXT: ret i64 0
|
|
|
|
;
|
2011-08-30 03:58:36 +08:00
|
|
|
%A = bitcast <2 x i32> zeroinitializer to x86_mmx
|
|
|
|
%B = bitcast x86_mmx %A to <2 x i32>
|
|
|
|
%C = bitcast <2 x i32> %B to i64
|
|
|
|
ret i64 %C
|
|
|
|
}
|
2012-05-11 09:32:59 +08:00
|
|
|
|
|
|
|
; PR12514
|
|
|
|
define i1 @test67(i1 %a, i32 %b) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test67(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
2012-05-11 09:32:59 +08:00
|
|
|
%tmp2 = zext i1 %a to i32
|
|
|
|
%conv6 = xor i32 %tmp2, 1
|
|
|
|
%and = and i32 %b, %conv6
|
|
|
|
%sext = shl nuw nsw i32 %and, 24
|
|
|
|
%neg.i = xor i32 %sext, -16777216
|
|
|
|
%conv.i.i = ashr exact i32 %neg.i, 24
|
|
|
|
%trunc = trunc i32 %conv.i.i to i8
|
|
|
|
%tobool.i = icmp eq i8 %trunc, 0
|
|
|
|
ret i1 %tobool.i
|
|
|
|
}
|
2012-10-23 16:28:26 +08:00
|
|
|
|
2015-12-15 09:44:07 +08:00
|
|
|
%s = type { i32, i32, i16 }
|
2012-10-23 16:28:26 +08:00
|
|
|
|
|
|
|
define %s @test68(%s *%p, i64 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test68(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s* %p, i64 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = mul i64 %i, 12
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
2014-02-14 08:49:12 +08:00
|
|
|
; addrspacecasts should be eliminated.
|
|
|
|
define %s @test68_addrspacecast(%s* %p, i64 %i) {
|
|
|
|
; CHECK-LABEL: @test68_addrspacecast(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s* %p, i64 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2014-02-14 08:49:12 +08:00
|
|
|
%o = mul i64 %i, 12
|
|
|
|
%q = addrspacecast %s* %p to i8 addrspace(2)*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8 addrspace(2)* %q, i64 %o
|
2014-02-14 08:49:12 +08:00
|
|
|
%r = addrspacecast i8 addrspace(2)* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2014-02-14 08:49:12 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test68_addrspacecast_2(%s* %p, i64 %i) {
|
|
|
|
; CHECK-LABEL: @test68_addrspacecast_2(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s* %p, i64 %i
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = addrspacecast %s* [[PP1]] to %s addrspace(1)*
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s addrspace(1)* [[R]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2014-02-14 08:49:12 +08:00
|
|
|
%o = mul i64 %i, 12
|
|
|
|
%q = addrspacecast %s* %p to i8 addrspace(2)*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8 addrspace(2)* %q, i64 %o
|
2014-02-14 08:49:12 +08:00
|
|
|
%r = addrspacecast i8 addrspace(2)* %pp to %s addrspace(1)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s addrspace(1)* %r
|
2014-02-14 08:49:12 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
2013-08-20 06:17:40 +08:00
|
|
|
define %s @test68_as1(%s addrspace(1)* %p, i32 %i) {
|
|
|
|
; CHECK-LABEL: @test68_as1(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s addrspace(1)* %p, i32 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s addrspace(1)* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2013-08-20 06:17:40 +08:00
|
|
|
%o = mul i32 %i, 12
|
|
|
|
%q = bitcast %s addrspace(1)* %p to i8 addrspace(1)*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8 addrspace(1)* %q, i32 %o
|
2013-08-20 06:17:40 +08:00
|
|
|
%r = bitcast i8 addrspace(1)* %pp to %s addrspace(1)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s addrspace(1)* %r
|
2013-08-20 06:17:40 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
2012-10-23 16:28:26 +08:00
|
|
|
define double @test69(double *%p, i64 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test69(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr inbounds double, double* %p, i64 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = shl nsw i64 %i, 3
|
|
|
|
%q = bitcast double* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test70(%s *%p, i64 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test70(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O:%.*]] = mul nsw i64 %i, 3
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr inbounds %s, %s* %p, i64 [[O]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = mul nsw i64 %i, 36
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test71(double *%p, i64 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test71(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O:%.*]] = shl i64 %i, 2
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr double, double* %p, i64 [[O]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = shl i64 %i, 5
|
|
|
|
%q = bitcast double* %p to i8*
|
[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
|
|
|
%pp = getelementptr i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test72(double *%p, i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test72(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O:%.*]] = sext i32 %i to i64
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr inbounds double, double* %p, i64 [[O]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%so = shl nsw i32 %i, 3
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = sext i32 %so to i64
|
|
|
|
%q = bitcast double* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test73(double *%p, i128 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test73(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O:%.*]] = trunc i128 %i to i64
|
2016-06-17 14:28:53 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr double, double* %p, i64 [[O]]
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%lo = shl nsw i128 %i, 3
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = trunc i128 %lo to i64
|
|
|
|
%q = bitcast double* %p to i8*
|
2016-06-18 07:36:38 +08:00
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test74(double *%p, i64 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test74(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr inbounds double, double* %p, i64 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%q = bitcast double* %p to i64*
|
[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
|
|
|
%pp = getelementptr inbounds i64, i64* %q, i64 %i
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i64* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @test75(i32* %p, i32 %x) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test75(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[Y:%.*]] = shl i32 %x, 3
|
|
|
|
; CHECK-NEXT: [[Z:%.*]] = sext i32 [[Y]] to i64
|
|
|
|
; CHECK-NEXT: [[Q:%.*]] = bitcast i32* %p to i8*
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = getelementptr i8, i8* [[Q]], i64 [[Z]]
|
|
|
|
; CHECK-NEXT: [[S:%.*]] = bitcast i8* [[R]] to i32*
|
|
|
|
; CHECK-NEXT: ret i32* [[S]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%y = shl i32 %x, 3
|
|
|
|
%z = sext i32 %y to i64
|
|
|
|
%q = bitcast i32* %p to i8*
|
[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
|
|
|
%r = getelementptr i8, i8* %q, i64 %z
|
2012-10-23 16:28:26 +08:00
|
|
|
%s = bitcast i8* %r to i32*
|
|
|
|
ret i32* %s
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test76(%s *%p, i64 %i, i64 %j) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test76(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O2:%.*]] = mul i64 %i, %j
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s* %p, i64 [[O2]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = mul i64 %i, 12
|
|
|
|
%o2 = mul nsw i64 %o, %j
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o2
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test77(%s *%p, i64 %i, i64 %j) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test77(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[O:%.*]] = mul nsw i64 %i, 3
|
|
|
|
; CHECK-NEXT: [[O2:%.*]] = mul nsw i64 [[O]], %j
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr inbounds %s, %s* %p, i64 [[O2]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%o = mul nsw i64 %i, 36
|
|
|
|
%o2 = mul nsw i64 %o, %j
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %o2
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test78(%s *%p, i64 %i, i64 %j, i32 %k, i32 %l, i128 %m, i128 %n) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test78(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = mul nsw i32 %k, 3
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = mul nsw i32 [[A]], %l
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = sext i32 [[B]] to i128
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = mul nsw i128 [[C]], %m
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = mul i128 [[D]], %n
|
|
|
|
; CHECK-NEXT: [[F:%.*]] = trunc i128 [[E]] to i64
|
|
|
|
; CHECK-NEXT: [[G:%.*]] = mul i64 [[F]], %i
|
|
|
|
; CHECK-NEXT: [[H:%.*]] = mul i64 [[G]], %j
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr %s, %s* %p, i64 [[H]]
|
|
|
|
; CHECK-NEXT: [[LOAD:%.*]] = load %s, %s* [[PP1]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[LOAD]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%a = mul nsw i32 %k, 36
|
|
|
|
%b = mul nsw i32 %a, %l
|
|
|
|
%c = sext i32 %b to i128
|
|
|
|
%d = mul nsw i128 %c, %m
|
|
|
|
%e = mul i128 %d, %n
|
|
|
|
%f = trunc i128 %e to i64
|
|
|
|
%g = mul nsw i64 %f, %i
|
|
|
|
%h = mul nsw i64 %g, %j
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i64 %h
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %load
|
|
|
|
}
|
|
|
|
|
|
|
|
define %s @test79(%s *%p, i64 %i, i32 %j) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test79(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = mul nsw i64 %i, 36
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = trunc i64 [[A]] to i32
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = mul i32 [[B]], %j
|
|
|
|
; CHECK-NEXT: [[Q:%.*]] = bitcast %s* %p to i8*
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[C]] to i64
|
|
|
|
; CHECK-NEXT: [[PP:%.*]] = getelementptr inbounds i8, i8* [[Q]], i64 [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = bitcast i8* [[PP]] to %s*
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load %s, %s* [[R]], align 4
|
|
|
|
; CHECK-NEXT: ret %s [[L]]
|
|
|
|
;
|
2012-10-23 16:28:26 +08:00
|
|
|
%a = mul nsw i64 %i, 36
|
|
|
|
%b = trunc i64 %a to i32
|
|
|
|
%c = mul i32 %b, %j
|
|
|
|
%q = bitcast %s* %p to i8*
|
[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
|
|
|
%pp = getelementptr inbounds i8, i8* %q, i32 %c
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to %s*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load %s, %s* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret %s %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test80([100 x double]* %p, i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test80(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 %i to i64
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr [100 x double], [100 x double]* %p, i64 0, i64 [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%tmp = shl nsw i32 %i, 3
|
2012-10-23 16:28:26 +08:00
|
|
|
%q = bitcast [100 x double]* %p to i8*
|
[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
|
|
|
%pp = getelementptr i8, i8* %q, i32 %tmp
|
2012-10-23 16:28:26 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-23 16:28:26 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
2012-10-24 15:17:20 +08:00
|
|
|
|
2014-02-14 08:49:12 +08:00
|
|
|
define double @test80_addrspacecast([100 x double] addrspace(1)* %p, i32 %i) {
|
|
|
|
; CHECK-LABEL: @test80_addrspacecast(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr [100 x double], [100 x double] addrspace(1)* %p, i32 0, i32 %i
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double addrspace(1)* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%tmp = shl nsw i32 %i, 3
|
2014-02-14 08:49:12 +08:00
|
|
|
%q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)*
|
[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
|
|
|
%pp = getelementptr i8, i8 addrspace(2)* %q, i32 %tmp
|
2014-02-14 08:49:12 +08:00
|
|
|
%r = addrspacecast i8 addrspace(2)* %pp to double addrspace(1)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double addrspace(1)* %r
|
2014-02-14 08:49:12 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @test80_addrspacecast_2([100 x double] addrspace(1)* %p, i32 %i) {
|
|
|
|
; CHECK-LABEL: @test80_addrspacecast_2(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr [100 x double], [100 x double] addrspace(1)* %p, i32 0, i32 %i
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = addrspacecast double addrspace(1)* [[PP1]] to double addrspace(3)*
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double addrspace(3)* [[R]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%tmp = shl nsw i32 %i, 3
|
2014-02-14 08:49:12 +08:00
|
|
|
%q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)*
|
[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
|
|
|
%pp = getelementptr i8, i8 addrspace(2)* %q, i32 %tmp
|
2014-02-14 08:49:12 +08:00
|
|
|
%r = addrspacecast i8 addrspace(2)* %pp to double addrspace(3)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double addrspace(3)* %r
|
2014-02-14 08:49:12 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
2013-08-20 06:17:40 +08:00
|
|
|
define double @test80_as1([100 x double] addrspace(1)* %p, i16 %i) {
|
|
|
|
; CHECK-LABEL: @test80_as1(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = sext i16 %i to i32
|
|
|
|
; CHECK-NEXT: [[PP1:%.*]] = getelementptr [100 x double], [100 x double] addrspace(1)* %p, i32 0, i32 [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double addrspace(1)* [[PP1]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2014-10-11 18:19:52 +08:00
|
|
|
%tmp = shl nsw i16 %i, 3
|
2013-08-20 06:17:40 +08:00
|
|
|
%q = bitcast [100 x double] addrspace(1)* %p to i8 addrspace(1)*
|
[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
|
|
|
%pp = getelementptr i8, i8 addrspace(1)* %q, i16 %tmp
|
2013-08-20 06:17:40 +08:00
|
|
|
%r = bitcast i8 addrspace(1)* %pp to double addrspace(1)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double addrspace(1)* %r
|
2013-08-20 06:17:40 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
|
|
|
|
2012-10-24 15:17:20 +08:00
|
|
|
define double @test81(double *%p, float %f) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test81(
|
|
|
|
; CHECK-NEXT: [[I:%.*]] = fptosi float %f to i64
|
|
|
|
; CHECK-NEXT: [[Q:%.*]] = bitcast double* %p to i8*
|
|
|
|
; CHECK-NEXT: [[PP:%.*]] = getelementptr i8, i8* [[Q]], i64 [[I]]
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = bitcast i8* [[PP]] to double*
|
|
|
|
; CHECK-NEXT: [[L:%.*]] = load double, double* [[R]], align 8
|
|
|
|
; CHECK-NEXT: ret double [[L]]
|
|
|
|
;
|
2012-10-24 15:17:20 +08:00
|
|
|
%i = fptosi float %f to i64
|
|
|
|
%q = bitcast double* %p to i8*
|
[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
|
|
|
%pp = getelementptr i8, i8* %q, i64 %i
|
2012-10-24 15:17:20 +08:00
|
|
|
%r = bitcast i8* %pp to double*
|
2015-02-28 05:17:42 +08:00
|
|
|
%l = load double, double* %r
|
2012-10-24 15:17:20 +08:00
|
|
|
ret double %l
|
|
|
|
}
|
2013-05-11 00:26:37 +08:00
|
|
|
|
|
|
|
define i64 @test82(i64 %A) nounwind {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test82(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 %A, 1
|
|
|
|
; CHECK-NEXT: [[E:%.*]] = and i64 [[TMP1]], 4294966784
|
|
|
|
; CHECK-NEXT: ret i64 [[E]]
|
|
|
|
;
|
2013-05-11 00:26:37 +08:00
|
|
|
%B = trunc i64 %A to i32
|
|
|
|
%C = lshr i32 %B, 8
|
|
|
|
%D = shl i32 %C, 9
|
|
|
|
%E = zext i32 %D to i64
|
|
|
|
ret i64 %E
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR15959
|
|
|
|
define i64 @test83(i16 %a, i64 %k) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test83(
|
|
|
|
; CHECK-NEXT: [[CONV:%.*]] = sext i16 %a to i32
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = add i64 %k, 4294967295
|
|
|
|
; CHECK-NEXT: [[SH_PROM:%.*]] = trunc i64 [[SUB]] to i32
|
|
|
|
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[CONV]], [[SH_PROM]]
|
|
|
|
; CHECK-NEXT: [[SH_PROM1:%.*]] = zext i32 [[SHL]] to i64
|
|
|
|
; CHECK-NEXT: ret i64 [[SH_PROM1]]
|
|
|
|
;
|
2013-05-11 00:26:37 +08:00
|
|
|
%conv = sext i16 %a to i32
|
|
|
|
%sub = add nsw i64 %k, -1
|
|
|
|
%sh_prom = trunc i64 %sub to i32
|
|
|
|
%shl = shl i32 %conv, %sh_prom
|
|
|
|
%sh_prom1 = zext i32 %shl to i64
|
|
|
|
ret i64 %sh_prom1
|
|
|
|
}
|
2014-08-22 15:56:32 +08:00
|
|
|
|
|
|
|
define i8 @test84(i32 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test84(
|
|
|
|
; CHECK-NEXT: [[ADD:%.*]] = add i32 %a, 2130706432
|
|
|
|
; CHECK-NEXT: [[SHR:%.*]] = lshr exact i32 [[ADD]], 23
|
|
|
|
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
|
|
|
|
; CHECK-NEXT: ret i8 [[TRUNC]]
|
|
|
|
;
|
2014-08-22 15:56:32 +08:00
|
|
|
%add = add nsw i32 %a, -16777216
|
|
|
|
%shr = lshr exact i32 %add, 23
|
|
|
|
%trunc = trunc i32 %shr to i8
|
|
|
|
ret i8 %trunc
|
|
|
|
}
|
2014-08-23 01:11:04 +08:00
|
|
|
|
|
|
|
define i8 @test85(i32 %a) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test85(
|
|
|
|
; CHECK-NEXT: [[ADD:%.*]] = add i32 %a, 2130706432
|
|
|
|
; CHECK-NEXT: [[SHR:%.*]] = lshr exact i32 [[ADD]], 23
|
|
|
|
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
|
|
|
|
; CHECK-NEXT: ret i8 [[TRUNC]]
|
|
|
|
;
|
2014-08-23 01:11:04 +08:00
|
|
|
%add = add nuw i32 %a, -16777216
|
|
|
|
%shr = lshr exact i32 %add, 23
|
|
|
|
%trunc = trunc i32 %shr to i8
|
|
|
|
ret i8 %trunc
|
|
|
|
}
|
2014-10-11 07:00:21 +08:00
|
|
|
|
2015-09-10 19:31:20 +08:00
|
|
|
define i16 @test86(i16 %v) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test86(
|
|
|
|
; CHECK-NEXT: [[S1:%.*]] = ashr i16 %v, 4
|
|
|
|
; CHECK-NEXT: ret i16 [[S1]]
|
|
|
|
;
|
2015-09-10 19:31:20 +08:00
|
|
|
%a = sext i16 %v to i32
|
|
|
|
%s = ashr i32 %a, 4
|
|
|
|
%t = trunc i32 %s to i16
|
|
|
|
ret i16 %t
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @test87(i16 %v) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test87(
|
|
|
|
; CHECK-NEXT: [[A1:%.*]] = ashr i16 %v, 12
|
|
|
|
; CHECK-NEXT: ret i16 [[A1]]
|
|
|
|
;
|
2015-09-10 19:31:20 +08:00
|
|
|
%c = sext i16 %v to i32
|
|
|
|
%m = mul nsw i32 %c, 16
|
|
|
|
%a = ashr i32 %m, 16
|
|
|
|
%t = trunc i32 %a to i16
|
|
|
|
ret i16 %t
|
|
|
|
}
|
|
|
|
|
2016-05-02 23:49:09 +08:00
|
|
|
; Do not optimize to ashr i16 (shift by 18)
|
2015-09-10 19:31:20 +08:00
|
|
|
define i16 @test88(i16 %v) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @test88(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = sext i16 %v to i32
|
|
|
|
; CHECK-NEXT: [[S:%.*]] = ashr i32 [[A]], 18
|
|
|
|
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[S]] to i16
|
|
|
|
; CHECK-NEXT: ret i16 [[T]]
|
|
|
|
;
|
2015-09-10 19:31:20 +08:00
|
|
|
%a = sext i16 %v to i32
|
|
|
|
%s = ashr i32 %a, 18
|
|
|
|
%t = trunc i32 %s to i16
|
|
|
|
ret i16 %t
|
|
|
|
}
|
|
|
|
|
2014-10-11 07:00:21 +08:00
|
|
|
; Overflow on a float to int or int to float conversion is undefined (PR21130).
|
|
|
|
|
|
|
|
define i8 @overflow_fptosi() {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @overflow_fptosi(
|
|
|
|
; CHECK-NEXT: ret i8 undef
|
|
|
|
;
|
2014-10-11 07:00:21 +08:00
|
|
|
%i = fptosi double 1.56e+02 to i8
|
|
|
|
ret i8 %i
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @overflow_fptoui() {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @overflow_fptoui(
|
|
|
|
; CHECK-NEXT: ret i8 undef
|
|
|
|
;
|
2014-10-11 07:00:21 +08:00
|
|
|
%i = fptoui double 2.56e+02 to i8
|
|
|
|
ret i8 %i
|
|
|
|
}
|
|
|
|
|
2016-05-02 22:21:55 +08:00
|
|
|
; The maximum float is approximately 2 ** 128 which is 3.4E38.
|
2014-10-11 07:00:21 +08:00
|
|
|
; The constant below is 4E38. Use a 130 bit integer to hold that
|
|
|
|
; number; 129-bits for the value + 1 bit for the sign.
|
|
|
|
define float @overflow_uitofp() {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @overflow_uitofp(
|
|
|
|
; CHECK-NEXT: ret float undef
|
|
|
|
;
|
2014-10-11 07:00:21 +08:00
|
|
|
%i = uitofp i130 400000000000000000000000000000000000000 to float
|
|
|
|
ret float %i
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @overflow_sitofp() {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @overflow_sitofp(
|
|
|
|
; CHECK-NEXT: ret float undef
|
|
|
|
;
|
2014-10-11 07:00:21 +08:00
|
|
|
%i = sitofp i130 400000000000000000000000000000000000000 to float
|
|
|
|
ret float %i
|
|
|
|
}
|
|
|
|
|
2014-10-27 13:47:49 +08:00
|
|
|
define i32 @PR21388(i32* %v) {
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-LABEL: @PR21388(
|
|
|
|
; CHECK-NEXT: [[ICMP:%.*]] = icmp slt i32* %v, null
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[ICMP]] to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[SEXT]]
|
|
|
|
;
|
2014-10-27 13:47:49 +08:00
|
|
|
%icmp = icmp slt i32* %v, null
|
|
|
|
%sext = sext i1 %icmp to i32
|
|
|
|
ret i32 %sext
|
|
|
|
}
|
2015-04-21 08:05:41 +08:00
|
|
|
|
|
|
|
define float @sitofp_zext(i16 %a) {
|
|
|
|
; CHECK-LABEL: @sitofp_zext(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[SITOFP:%.*]] = uitofp i16 %a to float
|
|
|
|
; CHECK-NEXT: ret float [[SITOFP]]
|
|
|
|
;
|
2015-04-21 08:05:41 +08:00
|
|
|
%zext = zext i16 %a to i32
|
|
|
|
%sitofp = sitofp i32 %zext to float
|
|
|
|
ret float %sitofp
|
|
|
|
}
|
2015-04-23 04:59:28 +08:00
|
|
|
|
|
|
|
define i1 @PR23309(i32 %A, i32 %B) {
|
|
|
|
; CHECK-LABEL: @PR23309(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub i32 %A, %B
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[SUB]], 1
|
|
|
|
; CHECK-NEXT: [[TRUNC:%.*]] = icmp ne i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[TRUNC]]
|
|
|
|
;
|
2015-04-23 04:59:28 +08:00
|
|
|
%add = add i32 %A, -4
|
|
|
|
%sub = sub nsw i32 %add, %B
|
|
|
|
%trunc = trunc i32 %sub to i1
|
|
|
|
ret i1 %trunc
|
|
|
|
}
|
2015-04-23 06:42:05 +08:00
|
|
|
|
|
|
|
define i1 @PR23309v2(i32 %A, i32 %B) {
|
|
|
|
; CHECK-LABEL: @PR23309v2(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = add i32 %A, %B
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[SUB]], 1
|
|
|
|
; CHECK-NEXT: [[TRUNC:%.*]] = icmp ne i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[TRUNC]]
|
|
|
|
;
|
2015-04-23 06:42:05 +08:00
|
|
|
%add = add i32 %A, -4
|
|
|
|
%sub = add nuw i32 %add, %B
|
|
|
|
%trunc = trunc i32 %sub to i1
|
|
|
|
ret i1 %trunc
|
|
|
|
}
|
2015-09-10 19:31:20 +08:00
|
|
|
|
|
|
|
define i16 @PR24763(i8 %V) {
|
|
|
|
; CHECK-LABEL: @PR24763(
|
2016-05-02 22:21:55 +08:00
|
|
|
; CHECK-NEXT: [[L:%.*]] = ashr i8 %V, 1
|
|
|
|
; CHECK-NEXT: [[T:%.*]] = sext i8 [[L]] to i16
|
|
|
|
; CHECK-NEXT: ret i16 [[T]]
|
|
|
|
;
|
2015-09-10 19:31:20 +08:00
|
|
|
%conv = sext i8 %V to i32
|
|
|
|
%l = lshr i32 %conv, 1
|
|
|
|
%t = trunc i32 %l to i16
|
|
|
|
ret i16 %t
|
|
|
|
}
|
2016-07-28 10:29:06 +08:00
|
|
|
|
|
|
|
define i64 @PR28745() {
|
|
|
|
; CHECK-LABEL: @PR28745(
|
2016-07-29 11:27:31 +08:00
|
|
|
; CHECK-NEXT: ret i64 1
|
2016-07-28 10:29:06 +08:00
|
|
|
|
|
|
|
%b = zext i32 extractvalue ({ i32 } select (i1 icmp eq (i16 extractelement (<2 x i16> bitcast (<1 x i32> <i32 1> to <2 x i16>), i32 0), i16 0), { i32 } { i32 1 }, { i32 } zeroinitializer), 0) to i64
|
|
|
|
ret i64 %b
|
|
|
|
}
|
2016-07-29 12:06:09 +08:00
|
|
|
|
|
|
|
define i32 @test89() {
|
|
|
|
; CHECK-LABEL: @test89(
|
|
|
|
; CHECK-NEXT: ret i32 393216
|
|
|
|
ret i32 bitcast (<2 x i16> <i16 6, i16 undef> to i32)
|
|
|
|
}
|
2016-07-30 02:48:27 +08:00
|
|
|
|
|
|
|
define <2 x i32> @test90() {
|
|
|
|
; CHECK-LABEL: @test90(
|
|
|
|
; CHECK: ret <2 x i32> <i32 0, i32 15360>
|
|
|
|
%tmp6 = bitcast <4 x half> <half undef, half undef, half undef, half 0xH3C00> to <2 x i32>
|
|
|
|
ret <2 x i32> %tmp6
|
|
|
|
}
|